[llvm-branch-commits] [cfe-branch] r158515 - in /cfe/branches/tooling: ./ bindings/python/clang/ bindings/python/tests/cindex/ docs/ include/clang-c/ include/clang/AST/ include/clang/Analysis/ include/clang/Analysis/Analyses/ include/clang/Basic/ include/clang/Driver/ include/clang/Frontend/ include/clang/Lex/ include/clang/Parse/ include/clang/Rewrite/ include/clang/Sema/ include/clang/Serialization/ include/clang/StaticAnalyzer/Core/PathSensitive/ include/clang/Tooling/ lib/ARCMigrate/ lib/AST/ lib/Analysis/ lib/Basic/ lib/...
Manuel Klimek
klimek at google.com
Fri Jun 15 04:08:29 PDT 2012
Author: klimek
Date: Fri Jun 15 06:08:27 2012
New Revision: 158515
URL: http://llvm.org/viewvc/llvm-project?rev=158515&view=rev
Log:
Merging mainline.
Added:
cfe/branches/tooling/docs/JSONCompilationDatabase.html
- copied unchanged from r158512, cfe/trunk/docs/JSONCompilationDatabase.html
cfe/branches/tooling/lib/Headers/xopintrin.h
- copied unchanged from r158512, cfe/trunk/lib/Headers/xopintrin.h
cfe/branches/tooling/lib/Rewrite/InclusionRewriter.cpp
- copied unchanged from r158512, cfe/trunk/lib/Rewrite/InclusionRewriter.cpp
cfe/branches/tooling/test/ARCMT/objcmt-subscripting-literals-in-arc.m
- copied unchanged from r158512, cfe/trunk/test/ARCMT/objcmt-subscripting-literals-in-arc.m
cfe/branches/tooling/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result
- copied unchanged from r158512, cfe/trunk/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result
cfe/branches/tooling/test/Analysis/objc-for.m
- copied unchanged from r158512, cfe/trunk/test/Analysis/objc-for.m
cfe/branches/tooling/test/CXX/temp/temp.names/p3-0x.cpp
- copied unchanged from r158512, cfe/trunk/test/CXX/temp/temp.names/p3-0x.cpp
cfe/branches/tooling/test/CodeGen/alloca.c
- copied unchanged from r158512, cfe/trunk/test/CodeGen/alloca.c
cfe/branches/tooling/test/CodeGen/xop-builtins.c
- copied unchanged from r158512, cfe/trunk/test/CodeGen/xop-builtins.c
cfe/branches/tooling/test/CodeGenCXX/mangle-ms-abi-examples.cpp
- copied unchanged from r158512, cfe/trunk/test/CodeGenCXX/mangle-ms-abi-examples.cpp
cfe/branches/tooling/test/FixIt/messages.cpp
- copied unchanged from r158512, cfe/trunk/test/FixIt/messages.cpp
cfe/branches/tooling/test/Frontend/Inputs/SystemHeaderPrefix/
- copied from r158512, cfe/trunk/test/Frontend/Inputs/SystemHeaderPrefix/
cfe/branches/tooling/test/Frontend/Inputs/SystemHeaderPrefix/libs/
- copied from r158512, cfe/trunk/test/Frontend/Inputs/SystemHeaderPrefix/libs/
cfe/branches/tooling/test/Frontend/Inputs/SystemHeaderPrefix/libs/boost/
- copied from r158512, cfe/trunk/test/Frontend/Inputs/SystemHeaderPrefix/libs/boost/
cfe/branches/tooling/test/Frontend/Inputs/SystemHeaderPrefix/libs/boost/all.h
- copied unchanged from r158512, cfe/trunk/test/Frontend/Inputs/SystemHeaderPrefix/libs/boost/all.h
cfe/branches/tooling/test/Frontend/Inputs/SystemHeaderPrefix/libs/boost/warn.h
- copied unchanged from r158512, cfe/trunk/test/Frontend/Inputs/SystemHeaderPrefix/libs/boost/warn.h
cfe/branches/tooling/test/Frontend/Inputs/SystemHeaderPrefix/libs/mylib/
- copied from r158512, cfe/trunk/test/Frontend/Inputs/SystemHeaderPrefix/libs/mylib/
cfe/branches/tooling/test/Frontend/Inputs/SystemHeaderPrefix/libs/mylib/all.h
- copied unchanged from r158512, cfe/trunk/test/Frontend/Inputs/SystemHeaderPrefix/libs/mylib/all.h
cfe/branches/tooling/test/Frontend/Inputs/SystemHeaderPrefix/libs/mylib/warn.h
- copied unchanged from r158512, cfe/trunk/test/Frontend/Inputs/SystemHeaderPrefix/libs/mylib/warn.h
cfe/branches/tooling/test/Frontend/Inputs/SystemHeaderPrefix/src/
- copied from r158512, cfe/trunk/test/Frontend/Inputs/SystemHeaderPrefix/src/
cfe/branches/tooling/test/Frontend/Inputs/SystemHeaderPrefix/src/all.h
- copied unchanged from r158512, cfe/trunk/test/Frontend/Inputs/SystemHeaderPrefix/src/all.h
cfe/branches/tooling/test/Frontend/Inputs/SystemHeaderPrefix/src/warn.h
- copied unchanged from r158512, cfe/trunk/test/Frontend/Inputs/SystemHeaderPrefix/src/warn.h
cfe/branches/tooling/test/Frontend/Inputs/rewrite-includes1.h
- copied unchanged from r158512, cfe/trunk/test/Frontend/Inputs/rewrite-includes1.h
cfe/branches/tooling/test/Frontend/Inputs/rewrite-includes2.h
- copied unchanged from r158512, cfe/trunk/test/Frontend/Inputs/rewrite-includes2.h
cfe/branches/tooling/test/Frontend/Inputs/rewrite-includes3.h
- copied unchanged from r158512, cfe/trunk/test/Frontend/Inputs/rewrite-includes3.h
cfe/branches/tooling/test/Frontend/Inputs/rewrite-includes4.h
- copied unchanged from r158512, cfe/trunk/test/Frontend/Inputs/rewrite-includes4.h
cfe/branches/tooling/test/Frontend/Inputs/rewrite-includes5.h
- copied unchanged from r158512, cfe/trunk/test/Frontend/Inputs/rewrite-includes5.h
cfe/branches/tooling/test/Frontend/Inputs/rewrite-includes6.h
- copied unchanged from r158512, cfe/trunk/test/Frontend/Inputs/rewrite-includes6.h
cfe/branches/tooling/test/Frontend/Inputs/rewrite-includes7.h
- copied unchanged from r158512, cfe/trunk/test/Frontend/Inputs/rewrite-includes7.h
cfe/branches/tooling/test/Frontend/rewrite-includes-missing.c
- copied unchanged from r158512, cfe/trunk/test/Frontend/rewrite-includes-missing.c
cfe/branches/tooling/test/Frontend/rewrite-includes.c
- copied unchanged from r158512, cfe/trunk/test/Frontend/rewrite-includes.c
cfe/branches/tooling/test/Frontend/system-header-prefix.c
- copied unchanged from r158512, cfe/trunk/test/Frontend/system-header-prefix.c
cfe/branches/tooling/test/Misc/ast-dump-wchar.cpp
- copied unchanged from r158512, cfe/trunk/test/Misc/ast-dump-wchar.cpp
cfe/branches/tooling/test/PCH/empty-with-headers.c
- copied unchanged from r158512, cfe/trunk/test/PCH/empty-with-headers.c
cfe/branches/tooling/test/Parser/completely-empty-header-file.h
- copied unchanged from r158512, cfe/trunk/test/Parser/completely-empty-header-file.h
cfe/branches/tooling/test/Parser/empty-translation-unit.c
- copied unchanged from r158512, cfe/trunk/test/Parser/empty-translation-unit.c
cfe/branches/tooling/test/Preprocessor/macro_paste_identifier_error.c
- copied unchanged from r158512, cfe/trunk/test/Preprocessor/macro_paste_identifier_error.c
cfe/branches/tooling/test/SemaObjC/objc-literal-comparison.m
- copied unchanged from r158512, cfe/trunk/test/SemaObjC/objc-literal-comparison.m
cfe/branches/tooling/utils/TableGen/TableGenBackends.h
- copied unchanged from r158512, cfe/trunk/utils/TableGen/TableGenBackends.h
cfe/branches/tooling/www/analyzer/faq.html
- copied unchanged from r158512, cfe/trunk/www/analyzer/faq.html
cfe/branches/tooling/www/analyzer/images/example_custom_assert.png
- copied unchanged from r158512, cfe/trunk/www/analyzer/images/example_custom_assert.png
cfe/branches/tooling/www/analyzer/images/example_null_pointer.png
- copied unchanged from r158512, cfe/trunk/www/analyzer/images/example_null_pointer.png
cfe/branches/tooling/www/analyzer/images/example_use_assert.png
- copied unchanged from r158512, cfe/trunk/www/analyzer/images/example_use_assert.png
Removed:
cfe/branches/tooling/test/CodeGen/2002-05-24-Alloca.c
cfe/branches/tooling/utils/TableGen/ClangASTNodesEmitter.h
cfe/branches/tooling/utils/TableGen/ClangDiagnosticsEmitter.h
cfe/branches/tooling/utils/TableGen/ClangSACheckersEmitter.h
cfe/branches/tooling/utils/TableGen/OptParserEmitter.h
Modified:
cfe/branches/tooling/ (props changed)
cfe/branches/tooling/CMakeLists.txt
cfe/branches/tooling/bindings/python/clang/cindex.py
cfe/branches/tooling/bindings/python/tests/cindex/test_cursor.py
cfe/branches/tooling/bindings/python/tests/cindex/test_location.py
cfe/branches/tooling/docs/InternalsManual.html
cfe/branches/tooling/docs/LibTooling.html
cfe/branches/tooling/docs/UsersManual.html
cfe/branches/tooling/include/clang-c/Index.h
cfe/branches/tooling/include/clang/AST/ASTContext.h
cfe/branches/tooling/include/clang/AST/Attr.h
cfe/branches/tooling/include/clang/AST/Decl.h
cfe/branches/tooling/include/clang/AST/DeclBase.h
cfe/branches/tooling/include/clang/AST/DeclCXX.h
cfe/branches/tooling/include/clang/AST/DeclObjC.h
cfe/branches/tooling/include/clang/AST/EvaluatedExprVisitor.h
cfe/branches/tooling/include/clang/AST/Expr.h
cfe/branches/tooling/include/clang/AST/ExprCXX.h
cfe/branches/tooling/include/clang/AST/ExprObjC.h
cfe/branches/tooling/include/clang/AST/NSAPI.h
cfe/branches/tooling/include/clang/AST/RecursiveASTVisitor.h
cfe/branches/tooling/include/clang/AST/Stmt.h
cfe/branches/tooling/include/clang/AST/StmtObjC.h
cfe/branches/tooling/include/clang/AST/TemplateBase.h
cfe/branches/tooling/include/clang/AST/Type.h
cfe/branches/tooling/include/clang/Analysis/Analyses/ThreadSafety.h
cfe/branches/tooling/include/clang/Analysis/CFG.h
cfe/branches/tooling/include/clang/Analysis/CallGraph.h
cfe/branches/tooling/include/clang/Analysis/ProgramPoint.h
cfe/branches/tooling/include/clang/Basic/Builtins.def
cfe/branches/tooling/include/clang/Basic/BuiltinsX86.def
cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td
cfe/branches/tooling/include/clang/Basic/DiagnosticIDs.h
cfe/branches/tooling/include/clang/Basic/DiagnosticParseKinds.td
cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td
cfe/branches/tooling/include/clang/Basic/FileSystemStatCache.h
cfe/branches/tooling/include/clang/Basic/IdentifierTable.h
cfe/branches/tooling/include/clang/Basic/MacroBuilder.h
cfe/branches/tooling/include/clang/Basic/OperatorKinds.h
cfe/branches/tooling/include/clang/Basic/SourceManager.h
cfe/branches/tooling/include/clang/Basic/SourceManagerInternals.h
cfe/branches/tooling/include/clang/Basic/Specifiers.h
cfe/branches/tooling/include/clang/Basic/StmtNodes.td
cfe/branches/tooling/include/clang/Driver/CC1Options.td
cfe/branches/tooling/include/clang/Driver/Makefile
cfe/branches/tooling/include/clang/Driver/OptTable.h
cfe/branches/tooling/include/clang/Driver/Options.td
cfe/branches/tooling/include/clang/Driver/Types.h
cfe/branches/tooling/include/clang/Frontend/CompilerInvocation.h
cfe/branches/tooling/include/clang/Frontend/FrontendAction.h
cfe/branches/tooling/include/clang/Frontend/FrontendOptions.h
cfe/branches/tooling/include/clang/Frontend/HeaderSearchOptions.h
cfe/branches/tooling/include/clang/Frontend/PreprocessorOutputOptions.h
cfe/branches/tooling/include/clang/Lex/CodeCompletionHandler.h
cfe/branches/tooling/include/clang/Lex/HeaderSearch.h
cfe/branches/tooling/include/clang/Lex/Lexer.h
cfe/branches/tooling/include/clang/Lex/ModuleMap.h
cfe/branches/tooling/include/clang/Lex/PPCallbacks.h
cfe/branches/tooling/include/clang/Lex/Pragma.h
cfe/branches/tooling/include/clang/Lex/PreprocessingRecord.h
cfe/branches/tooling/include/clang/Lex/Preprocessor.h
cfe/branches/tooling/include/clang/Lex/PreprocessorLexer.h
cfe/branches/tooling/include/clang/Parse/Parser.h
cfe/branches/tooling/include/clang/Rewrite/FrontendActions.h
cfe/branches/tooling/include/clang/Rewrite/Rewriters.h
cfe/branches/tooling/include/clang/Sema/CodeCompleteConsumer.h
cfe/branches/tooling/include/clang/Sema/DeclSpec.h
cfe/branches/tooling/include/clang/Sema/Designator.h
cfe/branches/tooling/include/clang/Sema/ParsedTemplate.h
cfe/branches/tooling/include/clang/Sema/Scope.h
cfe/branches/tooling/include/clang/Sema/ScopeInfo.h
cfe/branches/tooling/include/clang/Sema/Sema.h
cfe/branches/tooling/include/clang/Sema/Template.h
cfe/branches/tooling/include/clang/Sema/Weak.h
cfe/branches/tooling/include/clang/Serialization/ASTBitCodes.h
cfe/branches/tooling/include/clang/Serialization/ASTReader.h
cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
cfe/branches/tooling/include/clang/Tooling/CompilationDatabase.h (props changed)
cfe/branches/tooling/include/clang/Tooling/Tooling.h (props changed)
cfe/branches/tooling/lib/ARCMigrate/ARCMT.cpp
cfe/branches/tooling/lib/ARCMigrate/TransAutoreleasePool.cpp
cfe/branches/tooling/lib/ARCMigrate/TransBlockObjCVariable.cpp
cfe/branches/tooling/lib/ARCMigrate/TransGCCalls.cpp
cfe/branches/tooling/lib/ARCMigrate/TransProperties.cpp
cfe/branches/tooling/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
cfe/branches/tooling/lib/ARCMigrate/TransUnbridgedCasts.cpp
cfe/branches/tooling/lib/ARCMigrate/TransUnusedInitDelegate.cpp
cfe/branches/tooling/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp
cfe/branches/tooling/lib/ARCMigrate/Transforms.h
cfe/branches/tooling/lib/AST/ASTContext.cpp
cfe/branches/tooling/lib/AST/ASTImporter.cpp
cfe/branches/tooling/lib/AST/Decl.cpp
cfe/branches/tooling/lib/AST/DeclBase.cpp
cfe/branches/tooling/lib/AST/DeclCXX.cpp
cfe/branches/tooling/lib/AST/DeclObjC.cpp
cfe/branches/tooling/lib/AST/DeclPrinter.cpp
cfe/branches/tooling/lib/AST/DumpXML.cpp
cfe/branches/tooling/lib/AST/Expr.cpp
cfe/branches/tooling/lib/AST/ExprConstant.cpp
cfe/branches/tooling/lib/AST/ItaniumMangle.cpp
cfe/branches/tooling/lib/AST/MicrosoftMangle.cpp
cfe/branches/tooling/lib/AST/RecordLayoutBuilder.cpp
cfe/branches/tooling/lib/AST/Stmt.cpp
cfe/branches/tooling/lib/AST/StmtDumper.cpp
cfe/branches/tooling/lib/AST/StmtPrinter.cpp
cfe/branches/tooling/lib/AST/StmtProfile.cpp
cfe/branches/tooling/lib/AST/TemplateBase.cpp
cfe/branches/tooling/lib/AST/VTableBuilder.cpp
cfe/branches/tooling/lib/Analysis/CFG.cpp
cfe/branches/tooling/lib/Analysis/CallGraph.cpp
cfe/branches/tooling/lib/Analysis/UninitializedValues.cpp
cfe/branches/tooling/lib/Basic/SourceManager.cpp
cfe/branches/tooling/lib/Basic/Targets.cpp
cfe/branches/tooling/lib/CodeGen/CGCXXABI.h
cfe/branches/tooling/lib/CodeGen/CGCall.cpp
cfe/branches/tooling/lib/CodeGen/CGClass.cpp
cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp
cfe/branches/tooling/lib/CodeGen/CGException.cpp
cfe/branches/tooling/lib/CodeGen/CGExpr.cpp
cfe/branches/tooling/lib/CodeGen/CGExprAgg.cpp
cfe/branches/tooling/lib/CodeGen/CGExprCXX.cpp
cfe/branches/tooling/lib/CodeGen/CGExprConstant.cpp
cfe/branches/tooling/lib/CodeGen/CGExprScalar.cpp
cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp
cfe/branches/tooling/lib/CodeGen/CGObjCMac.cpp
cfe/branches/tooling/lib/CodeGen/CGObjCRuntime.cpp
cfe/branches/tooling/lib/CodeGen/CGObjCRuntime.h
cfe/branches/tooling/lib/CodeGen/CGRecordLayoutBuilder.cpp
cfe/branches/tooling/lib/CodeGen/CGStmt.cpp
cfe/branches/tooling/lib/CodeGen/CodeGenFunction.h
cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp
cfe/branches/tooling/lib/CodeGen/CodeGenTBAA.cpp
cfe/branches/tooling/lib/CodeGen/CodeGenTBAA.h
cfe/branches/tooling/lib/CodeGen/TargetInfo.cpp
cfe/branches/tooling/lib/Driver/CMakeLists.txt
cfe/branches/tooling/lib/Driver/Tools.cpp
cfe/branches/tooling/lib/Driver/Tools.h
cfe/branches/tooling/lib/Edit/RewriteObjCFoundationAPI.cpp
cfe/branches/tooling/lib/Frontend/ASTUnit.cpp
cfe/branches/tooling/lib/Frontend/CMakeLists.txt
cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp
cfe/branches/tooling/lib/Frontend/FrontendAction.cpp
cfe/branches/tooling/lib/Frontend/InitHeaderSearch.cpp
cfe/branches/tooling/lib/Frontend/InitPreprocessor.cpp
cfe/branches/tooling/lib/Frontend/LayoutOverrideSource.cpp
cfe/branches/tooling/lib/Frontend/TextDiagnostic.cpp
cfe/branches/tooling/lib/FrontendTool/ExecuteCompilerInvocation.cpp
cfe/branches/tooling/lib/Headers/CMakeLists.txt
cfe/branches/tooling/lib/Headers/x86intrin.h
cfe/branches/tooling/lib/Lex/HeaderSearch.cpp
cfe/branches/tooling/lib/Lex/Lexer.cpp
cfe/branches/tooling/lib/Lex/LiteralSupport.cpp
cfe/branches/tooling/lib/Lex/PPDirectives.cpp
cfe/branches/tooling/lib/Lex/Pragma.cpp
cfe/branches/tooling/lib/Lex/Preprocessor.cpp
cfe/branches/tooling/lib/Lex/TokenLexer.cpp
cfe/branches/tooling/lib/Parse/ParseAST.cpp
cfe/branches/tooling/lib/Parse/ParseCXXInlineMethods.cpp
cfe/branches/tooling/lib/Parse/ParseDecl.cpp
cfe/branches/tooling/lib/Parse/ParseDeclCXX.cpp
cfe/branches/tooling/lib/Parse/ParseExpr.cpp
cfe/branches/tooling/lib/Parse/ParseExprCXX.cpp
cfe/branches/tooling/lib/Parse/ParseObjc.cpp
cfe/branches/tooling/lib/Parse/ParsePragma.h
cfe/branches/tooling/lib/Parse/ParseStmt.cpp
cfe/branches/tooling/lib/Parse/Parser.cpp
cfe/branches/tooling/lib/Parse/RAIIObjectsForParser.h
cfe/branches/tooling/lib/Rewrite/CMakeLists.txt
cfe/branches/tooling/lib/Rewrite/FrontendActions.cpp
cfe/branches/tooling/lib/Rewrite/HTMLRewrite.cpp
cfe/branches/tooling/lib/Rewrite/RewriteModernObjC.cpp
cfe/branches/tooling/lib/Rewrite/RewriteObjC.cpp
cfe/branches/tooling/lib/Sema/AnalysisBasedWarnings.cpp
cfe/branches/tooling/lib/Sema/DeclSpec.cpp
cfe/branches/tooling/lib/Sema/IdentifierResolver.cpp
cfe/branches/tooling/lib/Sema/Sema.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/SemaLambda.cpp
cfe/branches/tooling/lib/Sema/SemaLookup.cpp
cfe/branches/tooling/lib/Sema/SemaObjCProperty.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/SemaTemplateDeduction.cpp
cfe/branches/tooling/lib/Sema/SemaTemplateInstantiate.cpp
cfe/branches/tooling/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/branches/tooling/lib/Sema/SemaType.cpp
cfe/branches/tooling/lib/Sema/TreeTransform.h
cfe/branches/tooling/lib/Serialization/ASTReader.cpp
cfe/branches/tooling/lib/Serialization/ASTReaderDecl.cpp
cfe/branches/tooling/lib/Serialization/ASTReaderStmt.cpp
cfe/branches/tooling/lib/Serialization/ASTWriter.cpp
cfe/branches/tooling/lib/Serialization/ASTWriterDecl.cpp
cfe/branches/tooling/lib/Serialization/ASTWriterStmt.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/Checkers.td
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Core/AnalysisManager.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Core/MemRegion.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Core/RegionStore.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Core/SValBuilder.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
cfe/branches/tooling/lib/Tooling/CompilationDatabase.cpp (props changed)
cfe/branches/tooling/lib/Tooling/Tooling.cpp (props changed)
cfe/branches/tooling/test/ARCMT/nonobjc-to-objc-cast-2.m
cfe/branches/tooling/test/ARCMT/nonobjc-to-objc-cast.m
cfe/branches/tooling/test/ARCMT/nonobjc-to-objc-cast.m.result
cfe/branches/tooling/test/Analysis/inline-plist.c
cfe/branches/tooling/test/Analysis/malloc-plist.c
cfe/branches/tooling/test/Analysis/malloc-sizeof.c
cfe/branches/tooling/test/Analysis/malloc.c
cfe/branches/tooling/test/Analysis/plist-output-alternate.m
cfe/branches/tooling/test/Analysis/plist-output.m
cfe/branches/tooling/test/CMakeLists.txt (props changed)
cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
cfe/branches/tooling/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
cfe/branches/tooling/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp
cfe/branches/tooling/test/CXX/special/class.copy/p13-0x.cpp
cfe/branches/tooling/test/CXX/special/class.copy/p8-cxx11.cpp
cfe/branches/tooling/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp
cfe/branches/tooling/test/CodeGen/vla.c
cfe/branches/tooling/test/CodeGenCXX/exceptions.cpp
cfe/branches/tooling/test/CodeGenCXX/mangle-ms.cpp
cfe/branches/tooling/test/CodeGenCXX/visibility.cpp
cfe/branches/tooling/test/Driver/clang-translation.c
cfe/branches/tooling/test/Driver/warning-options.cpp
cfe/branches/tooling/test/FixIt/fixit.cpp
cfe/branches/tooling/test/FixIt/objc-literals.m
cfe/branches/tooling/test/Index/complete-method-decls.m
cfe/branches/tooling/test/Index/complete-properties.m
cfe/branches/tooling/test/Index/get-cursor.c
cfe/branches/tooling/test/Index/get-cursor.m
cfe/branches/tooling/test/Index/index-decls.m
cfe/branches/tooling/test/Index/pch-with-errors.c
cfe/branches/tooling/test/Lexer/c90.c
cfe/branches/tooling/test/Lexer/char-literal.cpp
cfe/branches/tooling/test/Lexer/hexfloat.cpp
cfe/branches/tooling/test/Misc/emit-html.c
cfe/branches/tooling/test/Misc/warning-flags.c
cfe/branches/tooling/test/PCH/cxx-member-init.cpp
cfe/branches/tooling/test/Parser/cxx-using-directive.cpp
cfe/branches/tooling/test/Parser/cxx11-type-specifier.cpp
cfe/branches/tooling/test/Parser/ms-inline-asm.c
cfe/branches/tooling/test/Parser/opencl-pragma.cl
cfe/branches/tooling/test/Preprocessor/comment_save.c
cfe/branches/tooling/test/Preprocessor/init.c
cfe/branches/tooling/test/Preprocessor/macro_paste_c_block_comment.c
cfe/branches/tooling/test/Preprocessor/predefined-arch-macros.c
cfe/branches/tooling/test/Preprocessor/undef-error.c
cfe/branches/tooling/test/Sema/c89-2.c
cfe/branches/tooling/test/SemaCXX/constructor-initializer.cpp
cfe/branches/tooling/test/SemaCXX/cxx0x-defaulted-functions.cpp
cfe/branches/tooling/test/SemaCXX/deleted-operator.cpp
cfe/branches/tooling/test/SemaCXX/elaborated-type-specifier.cpp
cfe/branches/tooling/test/SemaCXX/format-strings-0x.cpp
cfe/branches/tooling/test/SemaCXX/function-redecl.cpp
cfe/branches/tooling/test/SemaCXX/nested-name-spec.cpp
cfe/branches/tooling/test/SemaCXX/overloaded-builtin-operators.cpp
cfe/branches/tooling/test/SemaCXX/qualified-id-lookup.cpp
cfe/branches/tooling/test/SemaCXX/typo-correction.cpp
cfe/branches/tooling/test/SemaCXX/uninitialized.cpp
cfe/branches/tooling/test/SemaCXX/warn-unreachable.cpp (props changed)
cfe/branches/tooling/test/SemaCXX/warn-unused-member.cpp
cfe/branches/tooling/test/SemaObjC/arc-bridged-cast.m
cfe/branches/tooling/test/SemaObjC/cocoa-api-usage.m
cfe/branches/tooling/test/SemaObjC/cocoa-api-usage.m.fixed
cfe/branches/tooling/test/SemaObjCXX/arc-0x.mm
cfe/branches/tooling/test/SemaTemplate/instantiate-init.cpp
cfe/branches/tooling/test/SemaTemplate/typename-specifier.cpp
cfe/branches/tooling/test/Tooling/clang-check-pwd.cpp (props changed)
cfe/branches/tooling/test/Tooling/clang-check.cpp (props changed)
cfe/branches/tooling/tools/clang-check/ClangCheck.cpp (props changed)
cfe/branches/tooling/tools/clang-check/Makefile (props changed)
cfe/branches/tooling/tools/libclang/CIndex.cpp
cfe/branches/tooling/tools/libclang/CIndexUSRs.cpp
cfe/branches/tooling/tools/libclang/CMakeLists.txt
cfe/branches/tooling/tools/libclang/CXCursor.cpp
cfe/branches/tooling/tools/libclang/IndexDecl.cpp
cfe/branches/tooling/tools/libclang/RecursiveASTVisitor.h
cfe/branches/tooling/unittests/Tooling/CompilationDatabaseTest.cpp (props changed)
cfe/branches/tooling/unittests/Tooling/RecursiveASTVisitorTest.cpp
cfe/branches/tooling/unittests/Tooling/RewriterTestContext.h
cfe/branches/tooling/unittests/Tooling/ToolingTest.cpp (props changed)
cfe/branches/tooling/utils/TableGen/ClangASTNodesEmitter.cpp
cfe/branches/tooling/utils/TableGen/ClangAttrEmitter.cpp
cfe/branches/tooling/utils/TableGen/ClangDiagnosticsEmitter.cpp
cfe/branches/tooling/utils/TableGen/ClangSACheckersEmitter.cpp
cfe/branches/tooling/utils/TableGen/NeonEmitter.cpp
cfe/branches/tooling/utils/TableGen/OptParserEmitter.cpp
cfe/branches/tooling/utils/TableGen/TableGen.cpp
cfe/branches/tooling/utils/analyzer/CmpRuns.py
cfe/branches/tooling/utils/clang-completion-mode.el
cfe/branches/tooling/www/analyzer/annotations.html
cfe/branches/tooling/www/analyzer/content.css
cfe/branches/tooling/www/analyzer/menu.html.incl
Propchange: cfe/branches/tooling/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jun 15 06:08:27 2012
@@ -1,3 +1,3 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:146581-158060
+/cfe/trunk:146581-158512
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/tooling/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/CMakeLists.txt?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/CMakeLists.txt (original)
+++ cfe/branches/tooling/CMakeLists.txt Fri Jun 15 06:08:27 2012
@@ -198,14 +198,6 @@
link_system_libs( ${name} )
add_dependencies(${name} ClangDiagnosticCommon)
- if(MSVC)
- get_target_property(cflag ${name} COMPILE_FLAGS)
- if(NOT cflag)
- set(cflag "")
- endif(NOT cflag)
- set(cflag "${cflag} /Za")
- set_target_properties(${name} PROPERTIES COMPILE_FLAGS ${cflag})
- endif(MSVC)
install(TARGETS ${name}
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
Modified: cfe/branches/tooling/bindings/python/clang/cindex.py
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/bindings/python/clang/cindex.py?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/bindings/python/clang/cindex.py (original)
+++ cfe/branches/tooling/bindings/python/clang/cindex.py Fri Jun 15 06:08:27 2012
@@ -169,6 +169,16 @@
"""
return SourceLocation_getLocation(tu, file, line, column)
+ @staticmethod
+ def from_offset(tu, file, offset):
+ """Retrieve a SourceLocation from a given character offset.
+
+ tu -- TranslationUnit file belongs to
+ file -- File instance to obtain offset from
+ offset -- Integer character offset within file
+ """
+ return SourceLocation_getLocationForOffset(tu, file, offset)
+
@property
def file(self):
"""Get the file represented by this source location."""
@@ -677,7 +687,7 @@
CursorKind.COMPOUND_ASSIGNMENT_OPERATOR = CursorKind(115)
# The ?: ternary operator.
-CursorKind.CONDITONAL_OPERATOR = CursorKind(116)
+CursorKind.CONDITIONAL_OPERATOR = CursorKind(116)
# An explicit cast in C (C99 6.5.4) or a C-style cast in C++
# (C++ [expr.cast]), which uses the syntax (Type)expr.
@@ -949,6 +959,12 @@
"""
return Cursor_is_def(self)
+ def is_static_method(self):
+ """Returns True if the cursor refers to a C++ member function or member
+ function template that is declared 'static'.
+ """
+ return Cursor_is_static_method(self)
+
def get_definition(self):
"""
If the cursor is a reference to a declaration or a declaration of
@@ -2104,6 +2120,10 @@
SourceLocation_equalLocations.argtypes = [SourceLocation, SourceLocation]
SourceLocation_equalLocations.restype = bool
+SourceLocation_getLocationForOffset = lib.clang_getLocationForOffset
+SourceLocation_getLocationForOffset.argtypes = [TranslationUnit, File, c_uint]
+SourceLocation_getLocationForOffset.restype = SourceLocation
+
# Source Range Functions
SourceRange_getRange = lib.clang_getRange
SourceRange_getRange.argtypes = [SourceLocation, SourceLocation]
@@ -2176,6 +2196,10 @@
Cursor_is_def.argtypes = [Cursor]
Cursor_is_def.restype = bool
+Cursor_is_static_method = lib.clang_CXXMethod_isStatic
+Cursor_is_static_method.argtypes = [Cursor]
+Cursor_is_static_method.restype = bool
+
Cursor_def = lib.clang_getCursorDefinition
Cursor_def.argtypes = [Cursor]
Cursor_def.restype = Cursor
Modified: cfe/branches/tooling/bindings/python/tests/cindex/test_cursor.py
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/bindings/python/tests/cindex/test_cursor.py?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/bindings/python/tests/cindex/test_cursor.py (original)
+++ cfe/branches/tooling/bindings/python/tests/cindex/test_cursor.py Fri Jun 15 06:08:27 2012
@@ -102,6 +102,22 @@
assert len(cursors) == 3
assert cursors[1].canonical == cursors[2].canonical
+def test_is_static_method():
+ """Ensure Cursor.is_static_method works."""
+
+ source = 'class X { static void foo(); void bar(); };'
+ tu = get_tu(source, lang='cpp')
+
+ cls = get_cursor(tu, 'X')
+ foo = get_cursor(tu, 'foo')
+ bar = get_cursor(tu, 'bar')
+ assert cls is not None
+ assert foo is not None
+ assert bar is not None
+
+ assert foo.is_static_method()
+ assert not bar.is_static_method()
+
def test_underlying_type():
tu = get_tu('typedef int foo;')
typedef = get_cursor(tu, 'foo')
Modified: cfe/branches/tooling/bindings/python/tests/cindex/test_location.py
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/bindings/python/tests/cindex/test_location.py?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/bindings/python/tests/cindex/test_location.py (original)
+++ cfe/branches/tooling/bindings/python/tests/cindex/test_location.py Fri Jun 15 06:08:27 2012
@@ -60,6 +60,15 @@
location3 = SourceLocation.from_position(tu, file, 1, 4)
assert location2 != location3
+ offset_location = SourceLocation.from_offset(tu, file, 5)
+ cursor = Cursor.from_location(tu, offset_location)
+ verified = False
+ for n in [n for n in tu.cursor.get_children() if n.spelling == 'one']:
+ assert n == cursor
+ verified = True
+
+ assert verified
+
def test_extent():
tu = get_tu(baseInput)
one = get_cursor(tu, 'one')
Modified: cfe/branches/tooling/docs/InternalsManual.html
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/docs/InternalsManual.html?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/docs/InternalsManual.html (original)
+++ cfe/branches/tooling/docs/InternalsManual.html Fri Jun 15 06:08:27 2012
@@ -1764,18 +1764,6 @@
<h4>Boilerplate</h4>
-<p>Add an element to the <tt>AttributeList::Kind</tt> enum in <a
-href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?view=markup">include/clang/Sema/AttributeList.h</a>
-named <tt>AT_lower_with_underscores</tt>. That is, a CamelCased
-<tt>AttributeName</tt> in <tt>Attr.td</tt> name should become
-<tt>AT_attribute_name</tt>.</p>
-
-<p>Add a case to the <tt>StringSwitch</tt> in <tt>AttributeList::getKind()</tt>
-in <a
-href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AttributeList.cpp?view=markup">lib/Sema/AttributeList.cpp</a>
-for each spelling of your attribute. Less common attributes should come toward
-the end of that list.</p>
-
<p>Write a new <tt>HandleYourAttr()</tt> function in <a
href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?view=markup">lib/Sema/SemaDeclAttr.cpp</a>,
and add a case to the switch in <tt>ProcessNonInheritableDeclAttr()</tt> or
Modified: cfe/branches/tooling/docs/LibTooling.html
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/docs/LibTooling.html?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/docs/LibTooling.html (original)
+++ cfe/branches/tooling/docs/LibTooling.html Fri Jun 15 06:08:27 2012
@@ -180,6 +180,30 @@
</pre>
</p>
+<h3 id="linking">Linking.</h3>
+<p>Please note that this presents the linking requirements at the time of this
+writing. For the most up-to-date information, look at one of the tools'
+Makefiles (for example
+<a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-check/Makefile?view=markup">clang-check/Makefile</a>).
+</p>
+
+<p>To link a binary using the tooling infrastructure, link in the following
+libraries:
+<ul>
+<li>Tooling</li>
+<li>Frontend</li>
+<li>Driver</li>
+<li>Serialization</li>
+<li>Parse</li>
+<li>Sema</li>
+<li>Analysis</li>
+<li>Edit</li>
+<li>AST</li>
+<li>Lex</li>
+<li>Basic</li>
+</ul>
+</p>
+
</div>
</body>
</html>
Modified: cfe/branches/tooling/docs/UsersManual.html
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/docs/UsersManual.html?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/docs/UsersManual.html (original)
+++ cfe/branches/tooling/docs/UsersManual.html Fri Jun 15 06:08:27 2012
@@ -43,6 +43,7 @@
<li><a href="#diagnostics_categories">Diagnostic Categories</a></li>
<li><a href="#diagnostics_commandline">Controlling Diagnostics via Command Line Flags</a></li>
<li><a href="#diagnostics_pragmas">Controlling Diagnostics via Pragmas</a></li>
+ <li><a href="#diagnostics_systemheader">Controlling Diagnostics in System Headers</a></li>
<li><a href="#diagnostics_enable_everything">Enabling All Warnings</a></li>
<li><a href="#analyzer_diagnositics">Controlling Static Analyzer Diagnostics</a></li>
</ul>
@@ -654,6 +655,45 @@
compatible #pragmas there is no guarantee that they will have identical behaviour
on both compilers. </p>
+<h4 id="diagnostics_systemheader">Controlling Diagnostics in System Headers</h4>
+
+<p>Warnings are suppressed when they occur in system headers. By default, an
+included file is treated as a system header if it is found in an include path
+specified by <tt>-isystem</tt>, but this can be overridden in several ways.</p>
+
+<p>The <tt>system_header</tt> pragma can be used to mark the current file as
+being a system header. No warnings will be produced from the location of the
+pragma onwards within the same file.</p>
+
+<pre>
+char a = 'xy'; // warning
+
+#pragma clang system_header
+
+char b = 'ab'; // no warning
+</pre>
+
+<p>The <tt>-isystem-prefix</tt> and <tt>-ino-system-prefix</tt> command-line
+arguments can be used to override whether subsets of an include path are treated
+as system headers. When the name in a <tt>#include</tt> directive is found
+within a header search path and starts with a system prefix, the header is
+treated as a system header. The last prefix on the command-line which matches
+the specified header name takes precedence. For instance:</p>
+
+<pre>
+clang -Ifoo -isystem bar -isystem-prefix x/ -ino-system-prefix x/y/
+</pre>
+
+<p>Here, <tt>#include "x/a.h"</tt> is treated as including a system header, even
+if the header is found in <tt>foo</tt>, and <tt>#include "x/y/b.h"</tt> is
+treated as not including a system header, even if the header is found in
+<tt>bar</tt>.
+</p>
+
+<p>A <tt>#include</tt> directive which finds a file relative to the current
+directory is treated as including a system header if the including file is
+treated as a system header.</p>
+
<h4 id="diagnostics_enable_everything">Enabling All Warnings</h4>
<p>In addition to the traditional <tt>-W</tt> flags, one can enable <b>all</b>
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=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang-c/Index.h (original)
+++ cfe/branches/tooling/include/clang-c/Index.h Fri Jun 15 06:08:27 2012
@@ -190,8 +190,9 @@
*/
/**
- * \brief clang_createIndex() provides a shared context for creating
- * translation units. It provides two options:
+ * \brief Provides a shared context for creating translation units.
+ *
+ * It provides two options:
*
* - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
* declarations (when loading any new translation units). A "local" declaration
@@ -201,6 +202,7 @@
*
* Here is an example:
*
+ * \code
* // excludeDeclsFromPCH = 1, displayDiagnostics=1
* Idx = clang_createIndex(1, 1);
*
@@ -221,6 +223,7 @@
* clang_visitChildren(clang_getTranslationUnitCursor(TU),
* TranslationUnitVisitor, 0);
* clang_disposeTranslationUnit(TU);
+ * \endcode
*
* This process of creating the 'pch', loading it separately, and using it (via
* -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
@@ -246,16 +249,18 @@
/**
* \brief Used to indicate that threads that libclang creates for indexing
* purposes should use background priority.
- * Affects \see clang_indexSourceFile, \see clang_indexTranslationUnit,
- * \see clang_parseTranslationUnit, \see clang_saveTranslationUnit.
+ *
+ * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
+ * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
*/
CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
/**
* \brief Used to indicate that threads that libclang creates for editing
* purposes should use background priority.
- * Affects \see clang_reparseTranslationUnit, \see clang_codeCompleteAt,
- * \see clang_annotateTokens
+ *
+ * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
+ * #clang_annotateTokens
*/
CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
@@ -270,7 +275,7 @@
} CXGlobalOptFlags;
/**
- * \brief Sets general options associated with a CXIndex.
+ * \brief Sets general options associated with a CXIndex.
*
* For example:
* \code
@@ -317,7 +322,7 @@
/**
* \brief Determine whether the given header is guarded against
* multiple inclusions, either with the conventional
- * #ifndef/#define/#endif macro guards or with #pragma once.
+ * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
*/
CINDEX_LINKAGE unsigned
clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
@@ -382,7 +387,7 @@
CINDEX_LINKAGE CXSourceLocation clang_getNullLocation();
/**
- * \determine Determine whether two source locations, which must refer into
+ * \brief Determine whether two source locations, which must refer into
* the same translation unit, refer to exactly the same point in the source
* code.
*
@@ -467,12 +472,14 @@
*
* Example: given the following source code in a file somefile.c
*
+ * \code
* #123 "dummy.c" 1
*
* static int func(void)
* {
* return 0;
* }
+ * \endcode
*
* the location information returned by this function would be
*
@@ -509,7 +516,7 @@
* by the given source location.
*
* This interface has been replaced by the newer interface
- * \see clang_getExpansionLocation(). See that interface's documentation for
+ * #clang_getExpansionLocation(). See that interface's documentation for
* details.
*/
CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
@@ -622,7 +629,7 @@
/**
* \brief Retrieve a diagnostic associated with the given CXDiagnosticSet.
*
- * \param Unit the CXDiagnosticSet to query.
+ * \param Diags the CXDiagnosticSet to query.
* \param Index the zero-based diagnostic number to retrieve.
*
* \returns the requested diagnostic. This diagnostic must be freed
@@ -656,23 +663,23 @@
/**
* \brief Indicates that the serialized diagnostics file is invalid or
- * corrupt.
+ * corrupt.
*/
CXLoadDiag_InvalidFile = 3
};
/**
* \brief Deserialize a set of diagnostics from a Clang diagnostics bitcode
- * file.
+ * file.
*
- * \param The name of the file to deserialize.
- * \param A pointer to a enum value recording if there was a problem
+ * \param file The name of the file to deserialize.
+ * \param error A pointer to a enum value recording if there was a problem
* deserializing the diagnostics.
- * \param A pointer to a CXString for recording the error string
+ * \param errorString A pointer to a CXString for recording the error string
* if the file was not successfully loaded.
*
* \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These
- * diagnostics should be released using clang_disposeDiagnosticSet().
+ * diagnostics should be released using clang_disposeDiagnosticSet().
*/
CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file,
enum CXLoadDiag_Error *error,
@@ -684,8 +691,10 @@
CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags);
/**
- * \brief Retrieve the child diagnostics of a CXDiagnostic. This
- * CXDiagnosticSet does not need to be released by clang_diposeDiagnosticSet.
+ * \brief Retrieve the child diagnostics of a CXDiagnostic.
+ *
+ * This CXDiagnosticSet does not need to be released by
+ * clang_diposeDiagnosticSet.
*/
CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
@@ -878,7 +887,6 @@
/**
* \brief Retrieve the diagnostic category text for a given diagnostic.
*
- *
* \returns The text of the given diagnostic category.
*/
CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic);
@@ -974,12 +982,12 @@
* '-c'
* '-emit-ast'
* '-fsyntax-only'
- * '-o <output file>' (both '-o' and '<output file>' are ignored)
+ * '-o \<output file>' (both '-o' and '\<output file>' are ignored)
*
* \param CIdx The index object with which the translation unit will be
* associated.
*
- * \param source_filename - The name of the source file to load, or NULL if the
+ * \param source_filename The name of the source file to load, or NULL if the
* source file is included in \p clang_command_line_args.
*
* \param num_clang_command_line_args The number of command-line arguments in
@@ -989,7 +997,7 @@
* passed to the \c clang executable if it were being invoked out-of-process.
* These command-line options will be parsed and will affect how the translation
* unit is parsed. Note that the following options are ignored: '-c',
- * '-emit-ast', '-fsyntax-only' (which is the default), and '-o <output file>'.
+ * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
*
* \param num_unsaved_files the number of unsaved file entries in \p
* unsaved_files.
@@ -1138,7 +1146,7 @@
* passed to the \c clang executable if it were being invoked out-of-process.
* These command-line options will be parsed and will affect how the translation
* unit is parsed. Note that the following options are ignored: '-c',
- * '-emit-ast', '-fsyntax-only' (which is the default), and '-o <output file>'.
+ * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
*
* \param num_command_line_args The number of command-line arguments in
* \p command_line_args.
@@ -1434,13 +1442,13 @@
CXCursor_VarDecl = 9,
/** \brief A function or method parameter. */
CXCursor_ParmDecl = 10,
- /** \brief An Objective-C @interface. */
+ /** \brief An Objective-C \@interface. */
CXCursor_ObjCInterfaceDecl = 11,
- /** \brief An Objective-C @interface for a category. */
+ /** \brief An Objective-C \@interface for a category. */
CXCursor_ObjCCategoryDecl = 12,
- /** \brief An Objective-C @protocol declaration. */
+ /** \brief An Objective-C \@protocol declaration. */
CXCursor_ObjCProtocolDecl = 13,
- /** \brief An Objective-C @property declaration. */
+ /** \brief An Objective-C \@property declaration. */
CXCursor_ObjCPropertyDecl = 14,
/** \brief An Objective-C instance variable. */
CXCursor_ObjCIvarDecl = 15,
@@ -1448,9 +1456,9 @@
CXCursor_ObjCInstanceMethodDecl = 16,
/** \brief An Objective-C class method. */
CXCursor_ObjCClassMethodDecl = 17,
- /** \brief An Objective-C @implementation. */
+ /** \brief An Objective-C \@implementation. */
CXCursor_ObjCImplementationDecl = 18,
- /** \brief An Objective-C @implementation for a category. */
+ /** \brief An Objective-C \@implementation for a category. */
CXCursor_ObjCCategoryImplDecl = 19,
/** \brief A typedef */
CXCursor_TypedefDecl = 20,
@@ -1486,9 +1494,9 @@
CXCursor_UsingDeclaration = 35,
/** \brief A C++ alias declaration */
CXCursor_TypeAliasDecl = 36,
- /** \brief An Objective-C @synthesize definition. */
+ /** \brief An Objective-C \@synthesize definition. */
CXCursor_ObjCSynthesizeDecl = 37,
- /** \brief An Objective-C @dynamic definition. */
+ /** \brief An Objective-C \@dynamic definition. */
CXCursor_ObjCDynamicDecl = 38,
/** \brief An access specifier. */
CXCursor_CXXAccessSpecifier = 39,
@@ -1791,15 +1799,15 @@
*/
CXCursor_ObjCStringLiteral = 137,
- /** \brief An Objective-C @encode expression.
+ /** \brief An Objective-C \@encode expression.
*/
CXCursor_ObjCEncodeExpr = 138,
- /** \brief An Objective-C @selector expression.
+ /** \brief An Objective-C \@selector expression.
*/
CXCursor_ObjCSelectorExpr = 139,
- /** \brief An Objective-C @protocol expression.
+ /** \brief An Objective-C \@protocol expression.
*/
CXCursor_ObjCProtocolExpr = 140,
@@ -1944,23 +1952,23 @@
*/
CXCursor_AsmStmt = 215,
- /** \brief Objective-C's overall @try- at catch-@finally statement.
+ /** \brief Objective-C's overall \@try-\@catch-\@finally statement.
*/
CXCursor_ObjCAtTryStmt = 216,
- /** \brief Objective-C's @catch statement.
+ /** \brief Objective-C's \@catch statement.
*/
CXCursor_ObjCAtCatchStmt = 217,
- /** \brief Objective-C's @finally statement.
+ /** \brief Objective-C's \@finally statement.
*/
CXCursor_ObjCAtFinallyStmt = 218,
- /** \brief Objective-C's @throw statement.
+ /** \brief Objective-C's \@throw statement.
*/
CXCursor_ObjCAtThrowStmt = 219,
- /** \brief Objective-C's @synchronized statement.
+ /** \brief Objective-C's \@synchronized statement.
*/
CXCursor_ObjCAtSynchronizedStmt = 220,
@@ -1996,6 +2004,10 @@
*/
CXCursor_SEHFinallyStmt = 228,
+ /** \brief A MS inline assembly statement extension.
+ */
+ CXCursor_MSAsmStmt = 229,
+
/** \brief The null satement ";": C99 6.8.3p3.
*
* This cursor kind is used to describe the null statement.
@@ -2248,7 +2260,7 @@
* provided along with the unconditional deprecation of this entity. The client
* is responsible for deallocating this string.
*
- * \param always_unavailabile If non-NULL, will be set to indicate whether the
+ * \param always_unavailable If non-NULL, will be set to indicate whether the
* entity is unavailable on all platforms.
*
* \param unavailable_message If non-NULL, will be set to the message text
@@ -2683,10 +2695,10 @@
CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
/**
- * \determine Determine whether two CXTypes represent the same type.
+ * \brief Determine whether two CXTypes represent the same type.
*
- * \returns non-zero if the CXTypes represent the same type and
- zero otherwise.
+ * \returns non-zero if the CXTypes represent the same type and
+ * zero otherwise.
*/
CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
@@ -2701,26 +2713,28 @@
CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
/**
- * \determine Determine whether a CXType has the "const" qualifier set,
- * without looking through typedefs that may have added "const" at a different level.
+ * \brief Determine whether a CXType has the "const" qualifier set,
+ * without looking through typedefs that may have added "const" at a
+ * different level.
*/
CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
/**
- * \determine Determine whether a CXType has the "volatile" qualifier set,
- * without looking through typedefs that may have added "volatile" at a different level.
+ * \brief Determine whether a CXType has the "volatile" qualifier set,
+ * without looking through typedefs that may have added "volatile" at
+ * a different level.
*/
CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
/**
- * \determine Determine whether a CXType has the "restrict" qualifier set,
- * without looking through typedefs that may have added "restrict" at a different level.
+ * \brief Determine whether a CXType has the "restrict" qualifier set,
+ * without looking through typedefs that may have added "restrict" at a
+ * different level.
*/
CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
/**
* \brief For pointer types, returns the type of the pointee.
- *
*/
CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
@@ -2754,7 +2768,8 @@
CINDEX_LINKAGE CXType clang_getResultType(CXType T);
/**
- * \brief Retrieve the number of non-variadic arguments associated with a function type.
+ * \brief Retrieve the number of non-variadic arguments associated with a
+ * function type.
*
* If a non-function type is passed in, -1 is returned.
*/
@@ -2763,14 +2778,13 @@
/**
* \brief Retrieve the type of an argument of a function type.
*
- * If a non-function type is passed in or the function does not have enough parameters,
- * an invalid type is returned.
+ * If a non-function type is passed in or the function does not have enough
+ * parameters, an invalid type is returned.
*/
CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
/**
* \brief Return 1 if the CXType is a variadic function type, and 0 otherwise.
- *
*/
CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
@@ -3164,7 +3178,7 @@
* \brief If the cursor points to a selector identifier in a objc method or
* message expression, this returns the selector index.
*
- * After getting a cursor with \see clang_getCursor, this can be called to
+ * After getting a cursor with #clang_getCursor, this can be called to
* determine if the location points to a selector identifier.
*
* \returns The selector index if the cursor is an objc method or message
@@ -3278,8 +3292,8 @@
CXNameRange_WantQualifier = 0x1,
/**
- * \brief Include the explicit template arguments, e.g. <int> in x.f<int>, in
- * the range.
+ * \brief Include the explicit template arguments, e.g. \<int> in x.f<int>,
+ * in the range.
*/
CXNameRange_WantTemplateArgs = 0x2,
@@ -3798,7 +3812,7 @@
* \param kind If non-NULL, will be set to the kind of the parent context,
* or CXCursor_NotImplemented if there is no context.
*
- * \param Returns the name of the completion parent, e.g., "NSObject" if
+ * \returns The name of the completion parent, e.g., "NSObject" if
* the completion string represents a method in the NSObject class.
*/
CINDEX_LINKAGE CXString
@@ -4098,7 +4112,7 @@
/**
* \brief Retrieve a diagnostic associated with the given code completion.
*
- * \param Result the code completion results to query.
+ * \param Results the code completion results to query.
* \param Index the zero-based diagnostic number to retrieve.
*
* \returns the requested diagnostic. This diagnostic must be freed
@@ -4190,8 +4204,8 @@
/**
* \brief Enable/disable crash recovery.
*
- * \param Flag to indicate if crash recovery is enabled. A non-zero value
- * enables crash recovery, while 0 disables it.
+ * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero
+ * value enables crash recovery, while 0 disables it.
*/
CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
@@ -4200,7 +4214,7 @@
* (used with clang_getInclusions()).
*
* This visitor function will be invoked by clang_getInclusions() for each
- * file included (either at the top-level or by #include directives) within
+ * file included (either at the top-level or by \#include directives) within
* a translation unit. The first argument is the file being included, and
* the second and third arguments provide the inclusion stack. The
* array is sorted in order of immediate inclusion. For example,
@@ -4358,19 +4372,19 @@
} CXIdxLoc;
/**
- * \brief Data for \see ppIncludedFile callback.
+ * \brief Data for ppIncludedFile callback.
*/
typedef struct {
/**
- * \brief Location of '#' in the #include/#import directive.
+ * \brief Location of '#' in the \#include/\#import directive.
*/
CXIdxLoc hashLoc;
/**
- * \brief Filename as written in the #include/#import directive.
+ * \brief Filename as written in the \#include/\#import directive.
*/
const char *filename;
/**
- * \brief The actual file that the #include/#import directive resolved to.
+ * \brief The actual file that the \#include/\#import directive resolved to.
*/
CXFile file;
int isImport;
@@ -4378,7 +4392,7 @@
} CXIdxIncludedFileInfo;
/**
- * \brief Data for \see importedASTFile callback.
+ * \brief Data for IndexerCallbacks#importedASTFile.
*/
typedef struct {
CXFile file;
@@ -4492,7 +4506,7 @@
CXIdxLoc loc;
const CXIdxContainerInfo *semanticContainer;
/**
- * \brief Generally same as \see semanticContainer but can be different in
+ * \brief Generally same as #semanticContainer but can be different in
* cases like out-of-line C++ member functions.
*/
const CXIdxContainerInfo *lexicalContainer;
@@ -4564,7 +4578,7 @@
} CXIdxCXXClassDeclInfo;
/**
- * \brief Data for \see indexEntityReference callback.
+ * \brief Data for IndexerCallbacks#indexEntityReference.
*/
typedef enum {
/**
@@ -4579,7 +4593,7 @@
} CXIdxEntityRefKind;
/**
- * \brief Data for \see indexEntityReference callback.
+ * \brief Data for IndexerCallbacks#indexEntityReference.
*/
typedef struct {
CXIdxEntityRefKind kind;
@@ -4610,6 +4624,10 @@
const CXIdxContainerInfo *container;
} CXIdxEntityRefInfo;
+/**
+ * \brief A group of callbacks used by #clang_indexSourceFile and
+ * #clang_indexTranslationUnit.
+ */
typedef struct {
/**
* \brief Called periodically to check whether indexing should be aborted.
@@ -4624,10 +4642,10 @@
CXDiagnosticSet, void *reserved);
CXIdxClientFile (*enteredMainFile)(CXClientData client_data,
- CXFile mainFile, void *reserved);
+ CXFile mainFile, void *reserved);
/**
- * \brief Called when a file gets #included/#imported.
+ * \brief Called when a file gets \#included/\#imported.
*/
CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
const CXIdxIncludedFileInfo *);
@@ -4740,9 +4758,9 @@
CXIndexOpt_None = 0x0,
/**
- * \brief Used to indicate that \see indexEntityReference should be invoked
- * for only one reference of an entity per source file that does not also
- * include a declaration/definition of the entity.
+ * \brief Used to indicate that IndexerCallbacks#indexEntityReference should
+ * be invoked for only one reference of an entity per source file that does
+ * not also include a declaration/definition of the entity.
*/
CXIndexOpt_SuppressRedundantRefs = 0x1,
@@ -4766,7 +4784,7 @@
/**
* \brief Index the given source file and the translation unit corresponding
- * to that file via callbacks implemented through \see IndexerCallbacks.
+ * to that file via callbacks implemented through #IndexerCallbacks.
*
* \param client_data pointer data supplied by the client, which will
* be passed to the invoked callbacks.
@@ -4774,7 +4792,7 @@
* \param index_callbacks Pointer to indexing callbacks that the client
* implements.
*
- * \param index_callbacks_size Size of \see IndexerCallbacks structure that gets
+ * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
* passed in index_callbacks.
*
* \param index_options A bitmask of options that affects how indexing is
@@ -4786,7 +4804,7 @@
* \returns If there is a failure from which the there is no recovery, returns
* non-zero, otherwise returns 0.
*
- * The rest of the parameters are the same as \see clang_parseTranslationUnit.
+ * The rest of the parameters are the same as #clang_parseTranslationUnit.
*/
CINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction,
CXClientData client_data,
@@ -4803,7 +4821,7 @@
/**
* \brief Index the given translation unit via callbacks implemented through
- * \see IndexerCallbacks.
+ * #IndexerCallbacks.
*
* The order of callback invocations is not guaranteed to be the same as
* when indexing a source file. The high level order will be:
@@ -4812,7 +4830,7 @@
* -Declaration/reference callbacks invocations
* -Diagnostic callback invocations
*
- * The parameters are the same as \see clang_indexSourceFile.
+ * The parameters are the same as #clang_indexSourceFile.
*
* \returns If there is a failure from which the there is no recovery, returns
* non-zero, otherwise returns 0.
Modified: cfe/branches/tooling/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/ASTContext.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/ASTContext.h (original)
+++ cfe/branches/tooling/include/clang/AST/ASTContext.h Fri Jun 15 06:08:27 2012
@@ -1215,10 +1215,10 @@
const TemplateArgument &ArgPack) const;
enum GetBuiltinTypeError {
- GE_None, //< No error
- GE_Missing_stdio, //< Missing a type from <stdio.h>
- GE_Missing_setjmp, //< Missing a type from <setjmp.h>
- GE_Missing_ucontext //< Missing a type from <ucontext.h>
+ GE_None, ///< No error
+ GE_Missing_stdio, ///< Missing a type from <stdio.h>
+ GE_Missing_setjmp, ///< Missing a type from <setjmp.h>
+ GE_Missing_ucontext ///< Missing a type from <ucontext.h>
};
/// GetBuiltinType - Return the type for the specified builtin. If
@@ -1705,7 +1705,7 @@
/// \brief Get the implementation of ObjCCategoryDecl, or NULL if none exists.
ObjCCategoryImplDecl *getObjCImplementation(ObjCCategoryDecl *D);
- /// \brief returns true if there is at lease one @implementation in TU.
+ /// \brief returns true if there is at least one \@implementation in TU.
bool AnyObjCImplementation() {
return !ObjCImpls.empty();
}
Modified: cfe/branches/tooling/include/clang/AST/Attr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/Attr.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/Attr.h (original)
+++ cfe/branches/tooling/include/clang/AST/Attr.h Fri Jun 15 06:08:27 2012
@@ -1,4 +1,4 @@
-//===--- Attr.h - Classes for representing expressions ----------*- C++ -*-===//
+//===--- Attr.h - Classes for representing attributes ----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
Modified: cfe/branches/tooling/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/Decl.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/Decl.h (original)
+++ cfe/branches/tooling/include/clang/AST/Decl.h Fri Jun 15 06:08:27 2012
@@ -99,7 +99,7 @@
};
/// NamedDecl - This represents a decl with a name. Many decls have names such
-/// as ObjCMethodDecl, but not @class, etc.
+/// as ObjCMethodDecl, but not \@class, etc.
class NamedDecl : public Decl {
virtual void anchor();
/// Name - The name of this declaration, which is typically a normal
@@ -1152,7 +1152,7 @@
}
/// \brief Determine whether this variable is the exception variable in a
- /// C++ catch statememt or an Objective-C @catch statement.
+ /// C++ catch statememt or an Objective-C \@catch statement.
bool isExceptionVariable() const {
return VarDeclBits.ExceptionVar;
}
@@ -1183,7 +1183,7 @@
bool isARCPseudoStrong() const { return VarDeclBits.ARCPseudoStrong; }
void setARCPseudoStrong(bool ps) { VarDeclBits.ARCPseudoStrong = ps; }
- /// Whether this variable is (C++0x) constexpr.
+ /// Whether this variable is (C++11) constexpr.
bool isConstexpr() const { return VarDeclBits.IsConstexpr; }
void setConstexpr(bool IC) { VarDeclBits.IsConstexpr = IC; }
@@ -1736,9 +1736,9 @@
bool hasInheritedPrototype() const { return HasInheritedPrototype; }
void setHasInheritedPrototype(bool P = true) { HasInheritedPrototype = P; }
- /// Whether this is a (C++0x) constexpr function or constexpr constructor.
+ /// Whether this is a (C++11) constexpr function or constexpr constructor.
bool isConstexpr() const { return IsConstexpr; }
- void setConstexpr(bool IC) { IsConstexpr = IC; }
+ void setConstexpr(bool IC);
/// \brief Whether this function has been deleted.
///
@@ -2093,25 +2093,26 @@
bool Mutable : 1;
mutable unsigned CachedFieldIndex : 31;
- /// \brief A pointer to either the in-class initializer for this field (if
- /// the boolean value is false), or the bit width expression for this bit
- /// field (if the boolean value is true).
+ /// \brief An InClassInitStyle value, and either a bit width expression (if
+ /// the InClassInitStyle value is ICIS_NoInit), or a pointer to the in-class
+ /// initializer for this field (otherwise).
///
/// We can safely combine these two because in-class initializers are not
/// permitted for bit-fields.
///
- /// If the boolean is false and the initializer is null, then this field has
- /// an in-class initializer which has not yet been parsed and attached.
- llvm::PointerIntPair<Expr *, 1, bool> InitializerOrBitWidth;
+ /// If the InClassInitStyle is not ICIS_NoInit and the initializer is null,
+ /// then this field has an in-class initializer which has not yet been parsed
+ /// and attached.
+ llvm::PointerIntPair<Expr *, 2, unsigned> InitializerOrBitWidth;
protected:
FieldDecl(Kind DK, DeclContext *DC, SourceLocation StartLoc,
SourceLocation IdLoc, IdentifierInfo *Id,
QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable,
- bool HasInit)
+ InClassInitStyle InitStyle)
: DeclaratorDecl(DK, DC, IdLoc, Id, T, TInfo, StartLoc),
Mutable(Mutable), CachedFieldIndex(0),
- InitializerOrBitWidth(BW, !HasInit) {
- assert(!(BW && HasInit) && "got initializer for bitfield");
+ InitializerOrBitWidth(BW, InitStyle) {
+ assert((!BW || InitStyle == ICIS_NoInit) && "got initializer for bitfield");
}
public:
@@ -2119,7 +2120,7 @@
SourceLocation StartLoc, SourceLocation IdLoc,
IdentifierInfo *Id, QualType T,
TypeSourceInfo *TInfo, Expr *BW, bool Mutable,
- bool HasInit);
+ InClassInitStyle InitStyle);
static FieldDecl *CreateDeserialized(ASTContext &C, unsigned ID);
@@ -2130,12 +2131,10 @@
/// isMutable - Determines whether this field is mutable (C++ only).
bool isMutable() const { return Mutable; }
- /// \brief Set whether this field is mutable (C++ only).
- void setMutable(bool M) { Mutable = M; }
-
/// isBitfield - Determines whether this field is a bitfield.
bool isBitField() const {
- return InitializerOrBitWidth.getInt() && InitializerOrBitWidth.getPointer();
+ return getInClassInitStyle() == ICIS_NoInit &&
+ InitializerOrBitWidth.getPointer();
}
/// @brief Determines whether this is an unnamed bitfield.
@@ -2151,39 +2150,34 @@
return isBitField() ? InitializerOrBitWidth.getPointer() : 0;
}
unsigned getBitWidthValue(const ASTContext &Ctx) const;
- void setBitWidth(Expr *BW) {
- assert(!InitializerOrBitWidth.getPointer() &&
- "bit width or initializer already set");
- InitializerOrBitWidth.setPointer(BW);
- InitializerOrBitWidth.setInt(1);
- }
- /// removeBitWidth - Remove the bitfield width from this member.
- void removeBitWidth() {
- assert(isBitField() && "no bit width to remove");
- InitializerOrBitWidth.setPointer(0);
+
+ /// getInClassInitStyle - Get the kind of (C++11) in-class initializer which
+ /// this field has.
+ InClassInitStyle getInClassInitStyle() const {
+ return static_cast<InClassInitStyle>(InitializerOrBitWidth.getInt());
}
- /// hasInClassInitializer - Determine whether this member has a C++0x in-class
+ /// hasInClassInitializer - Determine whether this member has a C++11 in-class
/// initializer.
bool hasInClassInitializer() const {
- return !InitializerOrBitWidth.getInt();
+ return getInClassInitStyle() != ICIS_NoInit;
}
- /// getInClassInitializer - Get the C++0x in-class initializer for this
+ /// getInClassInitializer - Get the C++11 in-class initializer for this
/// member, or null if one has not been set. If a valid declaration has an
/// in-class initializer, but this returns null, then we have not parsed and
/// attached it yet.
Expr *getInClassInitializer() const {
return hasInClassInitializer() ? InitializerOrBitWidth.getPointer() : 0;
}
- /// setInClassInitializer - Set the C++0x in-class initializer for this
+ /// setInClassInitializer - Set the C++11 in-class initializer for this
/// member.
void setInClassInitializer(Expr *Init);
- /// removeInClassInitializer - Remove the C++0x in-class initializer from this
+ /// removeInClassInitializer - Remove the C++11 in-class initializer from this
/// member.
void removeInClassInitializer() {
- assert(!InitializerOrBitWidth.getInt() && "no initializer to remove");
+ assert(hasInClassInitializer() && "no initializer to remove");
InitializerOrBitWidth.setPointer(0);
- InitializerOrBitWidth.setInt(1);
+ InitializerOrBitWidth.setInt(ICIS_NoInit);
}
/// getParent - Returns the parent of this field declaration, which
@@ -2202,6 +2196,9 @@
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const FieldDecl *D) { return true; }
static bool classofKind(Kind K) { return K >= firstField && K <= lastField; }
+
+ friend class ASTDeclReader;
+ friend class ASTDeclWriter;
};
/// EnumConstantDecl - An instance of this object exists for each enum constant
@@ -3216,8 +3213,8 @@
/// @__experimental_modules_import std.vector;
/// \endcode
///
-/// Import declarations can also be implicitly generated from #include/#import
-/// directives.
+/// Import declarations can also be implicitly generated from
+/// \#include/\#import directives.
class ImportDecl : public Decl {
/// \brief The imported module, along with a bit that indicates whether
/// we have source-location information for each identifier in the module
Modified: cfe/branches/tooling/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/DeclBase.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/DeclBase.h (original)
+++ cfe/branches/tooling/include/clang/AST/DeclBase.h Fri Jun 15 06:08:27 2012
@@ -693,18 +693,17 @@
Decl *Starter;
public:
- typedef Decl value_type;
- typedef value_type& reference;
- typedef value_type* pointer;
+ typedef Decl *value_type;
+ typedef const value_type &reference;
+ typedef const value_type *pointer;
typedef std::forward_iterator_tag iterator_category;
- typedef std::ptrdiff_t difference_type;
+ typedef std::ptrdiff_t difference_type;
redecl_iterator() : Current(0) { }
explicit redecl_iterator(Decl *C) : Current(C), Starter(C) { }
- reference operator*() const { return *Current; }
- pointer operator->() const { return Current; }
- operator pointer() const { return Current; }
+ reference operator*() const { return Current; }
+ value_type operator->() const { return Current; }
redecl_iterator& operator++() {
assert(Current && "Advancing while iterator has reached end");
@@ -1143,7 +1142,7 @@
/// inline, its enclosing namespace, recursively.
bool InEnclosingNamespaceSetOf(const DeclContext *NS) const;
- /// \\brief Collects all of the declaration contexts that are semantically
+ /// \brief Collects all of the declaration contexts that are semantically
/// connected to this declaration context.
///
/// For declaration contexts that have multiple semantically connected but
@@ -1175,9 +1174,9 @@
Decl *Current;
public:
- typedef Decl* value_type;
- typedef Decl* reference;
- typedef Decl* pointer;
+ typedef Decl *value_type;
+ typedef const value_type &reference;
+ typedef const value_type *pointer;
typedef std::forward_iterator_tag iterator_category;
typedef std::ptrdiff_t difference_type;
@@ -1185,7 +1184,8 @@
explicit decl_iterator(Decl *C) : Current(C) { }
reference operator*() const { return Current; }
- pointer operator->() const { return Current; }
+ // This doesn't meet the iterator requirements, but it's convenient
+ value_type operator->() const { return Current; }
decl_iterator& operator++() {
Current = Current->getNextDeclInContext();
@@ -1209,14 +1209,14 @@
/// decls_begin/decls_end - Iterate over the declarations stored in
/// this context.
decl_iterator decls_begin() const;
- decl_iterator decls_end() const;
+ decl_iterator decls_end() const { return decl_iterator(); }
bool decls_empty() const;
/// noload_decls_begin/end - Iterate over the declarations stored in this
/// context that are currently loaded; don't attempt to retrieve anything
/// from an external source.
decl_iterator noload_decls_begin() const;
- decl_iterator noload_decls_end() const;
+ decl_iterator noload_decls_end() const { return decl_iterator(); }
/// specific_decl_iterator - Iterates over a subrange of
/// declarations stored in a DeclContext, providing only those that
@@ -1239,9 +1239,11 @@
}
public:
- typedef SpecificDecl value_type;
- typedef SpecificDecl& reference;
- typedef SpecificDecl* pointer;
+ typedef SpecificDecl *value_type;
+ // TODO: Add reference and pointer typedefs (with some appropriate proxy
+ // type) if we ever have a need for them.
+ typedef void reference;
+ typedef void pointer;
typedef std::iterator_traits<DeclContext::decl_iterator>::difference_type
difference_type;
typedef std::forward_iterator_tag iterator_category;
@@ -1260,8 +1262,9 @@
SkipToNextDecl();
}
- reference operator*() const { return *cast<SpecificDecl>(*Current); }
- pointer operator->() const { return &**this; }
+ value_type operator*() const { return cast<SpecificDecl>(*Current); }
+ // This doesn't meet the iterator requirements, but it's convenient
+ value_type operator->() const { return **this; }
specific_decl_iterator& operator++() {
++Current;
@@ -1313,9 +1316,11 @@
}
public:
- typedef SpecificDecl* value_type;
- typedef SpecificDecl* reference;
- typedef SpecificDecl* pointer;
+ typedef SpecificDecl *value_type;
+ // TODO: Add reference and pointer typedefs (with some appropriate proxy
+ // type) if we ever have a need for them.
+ typedef void reference;
+ typedef void pointer;
typedef std::iterator_traits<DeclContext::decl_iterator>::difference_type
difference_type;
typedef std::forward_iterator_tag iterator_category;
@@ -1334,8 +1339,8 @@
SkipToNextDecl();
}
- reference operator*() const { return cast<SpecificDecl>(*Current); }
- pointer operator->() const { return cast<SpecificDecl>(*Current); }
+ value_type operator*() const { return cast<SpecificDecl>(*Current); }
+ value_type operator->() const { return cast<SpecificDecl>(*Current); }
filtered_decl_iterator& operator++() {
++Current;
@@ -1635,23 +1640,6 @@
}
};
-// simplify_type - Allow clients to treat redecl_iterators just like Decl
-// pointers when using casting operators.
-template<> struct simplify_type< ::clang::Decl::redecl_iterator> {
- typedef ::clang::Decl *SimpleType;
- static SimpleType getSimplifiedValue(const ::clang::Decl::redecl_iterator
- &Val) {
- return Val;
- }
-};
-template<> struct simplify_type<const ::clang::Decl::redecl_iterator> {
- typedef ::clang::Decl *SimpleType;
- static SimpleType getSimplifiedValue(const ::clang::Decl::redecl_iterator
- &Val) {
- return Val;
- }
-};
-
} // end namespace llvm
#endif
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=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/DeclCXX.h (original)
+++ cfe/branches/tooling/include/clang/AST/DeclCXX.h Fri Jun 15 06:08:27 2012
@@ -98,7 +98,7 @@
namespace clang {
-/// AccessSpecDecl - An access specifier followed by colon ':'.
+/// @brief Represents an access specifier followed by colon ':'.
///
/// An objects of this class represents sugar for the syntactic occurrence
/// of an access specifier followed by a colon in the list of member
@@ -110,7 +110,7 @@
/// "access declarations" (C++98 11.3 [class.access.dcl]).
class AccessSpecDecl : public Decl {
virtual void anchor();
- /// ColonLoc - The location of the ':'.
+ /// \brief The location of the ':'.
SourceLocation ColonLoc;
AccessSpecDecl(AccessSpecifier AS, DeclContext *DC,
@@ -121,14 +121,14 @@
AccessSpecDecl(EmptyShell Empty)
: Decl(AccessSpec, Empty) { }
public:
- /// getAccessSpecifierLoc - The location of the access specifier.
+ /// \brief The location of the access specifier.
SourceLocation getAccessSpecifierLoc() const { return getLocation(); }
- /// setAccessSpecifierLoc - Sets the location of the access specifier.
+ /// \brief Sets the location of the access specifier.
void setAccessSpecifierLoc(SourceLocation ASLoc) { setLocation(ASLoc); }
- /// getColonLoc - The location of the colon following the access specifier.
+ /// \brief The location of the colon following the access specifier.
SourceLocation getColonLoc() const { return ColonLoc; }
- /// setColonLoc - Sets the location of the colon.
+ /// \brief Sets the location of the colon.
void setColonLoc(SourceLocation CLoc) { ColonLoc = CLoc; }
SourceRange getSourceRange() const LLVM_READONLY {
@@ -149,7 +149,7 @@
};
-/// CXXBaseSpecifier - A base class of a C++ class.
+/// \brief Represents a base class of a C++ class.
///
/// Each CXXBaseSpecifier represents a single, direct base class (or
/// struct) of a C++ class (or struct). It specifies the type of that
@@ -175,7 +175,7 @@
/// expansion.
SourceLocation EllipsisLoc;
- /// Virtual - Whether this is a virtual base class or not.
+ /// \brief Whether this is a virtual base class or not.
bool Virtual : 1;
/// BaseOfClass - Whether this is the base of a class (true) or of a
@@ -385,26 +385,10 @@
/// constructor for this class would be constexpr.
bool DefaultedDefaultConstructorIsConstexpr : 1;
- /// DefaultedCopyConstructorIsConstexpr - True if a defaulted copy
- /// constructor for this class would be constexpr.
- bool DefaultedCopyConstructorIsConstexpr : 1;
-
- /// DefaultedMoveConstructorIsConstexpr - True if a defaulted move
- /// constructor for this class would be constexpr.
- bool DefaultedMoveConstructorIsConstexpr : 1;
-
/// HasConstexprDefaultConstructor - True if this class has a constexpr
/// default constructor (either user-declared or implicitly declared).
bool HasConstexprDefaultConstructor : 1;
- /// HasConstexprCopyConstructor - True if this class has a constexpr copy
- /// constructor (either user-declared or implicitly declared).
- bool HasConstexprCopyConstructor : 1;
-
- /// HasConstexprMoveConstructor - True if this class has a constexpr move
- /// constructor (either user-declared or implicitly declared).
- bool HasConstexprMoveConstructor : 1;
-
/// HasTrivialCopyConstructor - True when this class has a trivial copy
/// constructor.
///
@@ -650,6 +634,9 @@
void markedVirtualFunctionPure();
friend void FunctionDecl::setPure(bool);
+ void markedConstructorConstexpr(CXXConstructorDecl *CD);
+ friend void FunctionDecl::setConstexpr(bool);
+
friend class ASTNodeImporter;
protected:
@@ -1102,40 +1089,12 @@
(!isUnion() || hasInClassInitializer());
}
- /// defaultedCopyConstructorIsConstexpr - Whether a defaulted copy
- /// constructor for this class would be constexpr.
- bool defaultedCopyConstructorIsConstexpr() const {
- return data().DefaultedCopyConstructorIsConstexpr;
- }
-
- /// defaultedMoveConstructorIsConstexpr - Whether a defaulted move
- /// constructor for this class would be constexpr.
- bool defaultedMoveConstructorIsConstexpr() const {
- return data().DefaultedMoveConstructorIsConstexpr;
- }
-
/// hasConstexprDefaultConstructor - Whether this class has a constexpr
/// default constructor.
bool hasConstexprDefaultConstructor() const {
return data().HasConstexprDefaultConstructor ||
(!data().UserDeclaredConstructor &&
- defaultedDefaultConstructorIsConstexpr() && isLiteral());
- }
-
- /// hasConstexprCopyConstructor - Whether this class has a constexpr copy
- /// constructor.
- bool hasConstexprCopyConstructor() const {
- return data().HasConstexprCopyConstructor ||
- (!data().DeclaredCopyConstructor &&
- data().DefaultedCopyConstructorIsConstexpr && isLiteral());
- }
-
- /// hasConstexprMoveConstructor - Whether this class has a constexpr move
- /// constructor.
- bool hasConstexprMoveConstructor() const {
- return data().HasConstexprMoveConstructor ||
- (needsImplicitMoveConstructor() &&
- data().DefaultedMoveConstructorIsConstexpr && isLiteral());
+ defaultedDefaultConstructorIsConstexpr());
}
// hasTrivialCopyConstructor - Whether this class has a trivial copy
@@ -1220,12 +1179,12 @@
/// This routine will return non-NULL for (non-templated) member
/// classes of class templates. For example, given:
///
- /// \code
+ /// @code
/// template<typename T>
/// struct X {
/// struct A { };
/// };
- /// \endcode
+ /// @endcode
///
/// The declaration for X<int>::A is a (non-templated) CXXRecordDecl
/// whose parent is the class template specialization X<int>. For
@@ -1650,13 +1609,13 @@
///
/// In the following example, \c f() has an lvalue ref-qualifier, \c g()
/// has an rvalue ref-qualifier, and \c h() has no ref-qualifier.
- /// \code
+ /// @code
/// struct X {
/// void f() &;
/// void g() &&;
/// void h();
/// };
- /// \endcode
+ /// @endcode
RefQualifierKind getRefQualifier() const {
return getType()->getAs<FunctionProtoType>()->getRefQualifier();
}
@@ -2476,7 +2435,9 @@
friend class ASTDeclReader;
};
-/// NamespaceAliasDecl - Represents a C++ namespace alias. For example:
+/// \brief Represents a C++ namespace alias.
+///
+/// For example:
///
/// @code
/// namespace Foo = Bar;
@@ -2563,17 +2524,19 @@
static bool classofKind(Kind K) { return K == NamespaceAlias; }
};
-/// UsingShadowDecl - Represents a shadow declaration introduced into
-/// a scope by a (resolved) using declaration. For example,
+/// \brief Represents a shadow declaration introduced into a scope by a
+/// (resolved) using declaration.
///
+/// For example,
+/// @code
/// namespace A {
/// void foo();
/// }
/// namespace B {
-/// using A::foo(); // <- a UsingDecl
-/// // Also creates a UsingShadowDecl for A::foo in B
+/// using A::foo; // <- a UsingDecl
+/// // Also creates a UsingShadowDecl for A::foo() in B
/// }
-///
+/// @endcode
class UsingShadowDecl : public NamedDecl {
virtual void anchor();
@@ -2635,8 +2598,12 @@
friend class ASTDeclWriter;
};
-/// UsingDecl - Represents a C++ using-declaration. For example:
+/// \brief Represents a C++ using-declaration.
+///
+/// For example:
+/// @code
/// using someNameSpace::someIdentifier;
+/// @endcode
class UsingDecl : public NamedDecl {
virtual void anchor();
@@ -2651,8 +2618,10 @@
DeclarationNameLoc DNLoc;
/// \brief The first shadow declaration of the shadow decl chain associated
- /// with this using declaration. The bool member of the pair store whether
- /// this decl has the 'typename' keyword.
+ /// with this using declaration.
+ ///
+ /// The bool member of the pair store whether this decl has the \c typename
+ /// keyword.
llvm::PointerIntPair<UsingShadowDecl *, 1, bool> FirstUsingShadow;
UsingDecl(DeclContext *DC, SourceLocation UL,
@@ -2761,14 +2730,17 @@
friend class ASTDeclWriter;
};
-/// UnresolvedUsingValueDecl - Represents a dependent using
-/// declaration which was not marked with 'typename'. Unlike
-/// non-dependent using declarations, these *only* bring through
+/// \brief Represents a dependent using declaration which was not marked with
+/// \c typename.
+///
+/// Unlike non-dependent using declarations, these *only* bring through
/// non-types; otherwise they would break two-phase lookup.
///
-/// template <class T> class A : public Base<T> {
+/// @code
+/// template \<class T> class A : public Base<T> {
/// using Base<T>::foo;
/// };
+/// @endcode
class UnresolvedUsingValueDecl : public ValueDecl {
virtual void anchor();
@@ -2832,14 +2804,16 @@
friend class ASTDeclWriter;
};
-/// UnresolvedUsingTypenameDecl - Represents a dependent using
-/// declaration which was marked with 'typename'.
+/// @brief Represents a dependent using declaration which was marked with
+/// \c typename.
///
-/// template <class T> class A : public Base<T> {
+/// @code
+/// template \<class T> class A : public Base<T> {
/// using typename Base<T>::foo;
/// };
+/// @endcode
///
-/// The type associated with a unresolved using typename decl is
+/// The type associated with an unresolved using typename decl is
/// currently always a typename type.
class UnresolvedUsingTypenameDecl : public TypeDecl {
virtual void anchor();
@@ -2893,7 +2867,7 @@
static bool classofKind(Kind K) { return K == UnresolvedUsingTypename; }
};
-/// StaticAssertDecl - Represents a C++0x static_assert declaration.
+/// \brief Represents a C++11 static_assert declaration.
class StaticAssertDecl : public Decl {
virtual void anchor();
Expr *AssertExpr;
@@ -2933,7 +2907,7 @@
friend class ASTDeclReader;
};
-/// Insertion operator for diagnostics. This allows sending AccessSpecifier's
+/// Insertion operator for diagnostics. This allows sending an AccessSpecifier
/// into a diagnostic with <<.
const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
AccessSpecifier AS);
Modified: cfe/branches/tooling/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/DeclObjC.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/DeclObjC.h (original)
+++ cfe/branches/tooling/include/clang/AST/DeclObjC.h Fri Jun 15 06:08:27 2012
@@ -136,7 +136,7 @@
mutable unsigned HasRedeclaration : 1;
// NOTE: VC++ treats enums as signed, avoid using ImplementationControl enum
- /// @required/@optional
+ /// \@required/\@optional
unsigned DeclImplementation : 2;
// NOTE: VC++ treats enums as signed, avoid using the ObjCDeclQualifier enum
@@ -415,7 +415,7 @@
bool isOverriding() const { return IsOverriding; }
void setOverriding(bool isOverriding) { IsOverriding = isOverriding; }
- // Related to protocols declared in @protocol
+ // Related to protocols declared in \@protocol
void setDeclImplementation(ImplementationControl ic) {
DeclImplementation = ic;
}
@@ -547,24 +547,28 @@
}
};
-/// ObjCInterfaceDecl - Represents an ObjC class declaration. For example:
+/// \brief Represents an ObjC class declaration.
///
+/// For example:
+///
+/// \code
/// // MostPrimitive declares no super class (not particularly useful).
-/// @interface MostPrimitive
+/// \@interface MostPrimitive
/// // no instance variables or methods.
-/// @end
+/// \@end
///
/// // NSResponder inherits from NSObject & implements NSCoding (a protocol).
-/// @interface NSResponder : NSObject <NSCoding>
+/// \@interface NSResponder : NSObject \<NSCoding>
/// { // instance variables are represented by ObjCIvarDecl.
/// id nextResponder; // nextResponder instance variable.
/// }
/// - (NSResponder *)nextResponder; // return a pointer to NSResponder.
/// - (void)mouseMoved:(NSEvent *)theEvent; // return void, takes a pointer
-/// @end // to an NSEvent.
+/// \@end // to an NSEvent.
+/// \endcode
///
-/// Unlike C/C++, forward class declarations are accomplished with @class.
-/// Unlike C/C++, @class allows for a list of classes to be forward declared.
+/// Unlike C/C++, forward class declarations are accomplished with \@class.
+/// Unlike C/C++, \@class allows for a list of classes to be forward declared.
/// Unlike C++, ObjC is a single-rooted class model. In Cocoa, classes
/// typically inherit from NSObject (an exception is NSProxy).
///
@@ -585,10 +589,10 @@
/// Class's super class.
ObjCInterfaceDecl *SuperClass;
- /// Protocols referenced in the @interface declaration
+ /// Protocols referenced in the \@interface declaration
ObjCProtocolList ReferencedProtocols;
- /// Protocols reference in both the @interface and class extensions.
+ /// Protocols reference in both the \@interface and class extensions.
ObjCList<ObjCProtocolDecl> AllReferencedProtocols;
/// \brief List of categories and class extensions defined for this class.
@@ -818,21 +822,21 @@
bool hasDefinition() const { return Data; }
/// \brief Retrieve the definition of this class, or NULL if this class
- /// has been forward-declared (with @class) but not yet defined (with
- /// @interface).
+ /// has been forward-declared (with \@class) but not yet defined (with
+ /// \@interface).
ObjCInterfaceDecl *getDefinition() {
return hasDefinition()? Data->Definition : 0;
}
/// \brief Retrieve the definition of this class, or NULL if this class
- /// has been forward-declared (with @class) but not yet defined (with
- /// @interface).
+ /// has been forward-declared (with \@class) but not yet defined (with
+ /// \@interface).
const ObjCInterfaceDecl *getDefinition() const {
return hasDefinition()? Data->Definition : 0;
}
/// \brief Starts the definition of this Objective-C class, taking it from
- /// a forward declaration (@class) to a definition (@interface).
+ /// a forward declaration (\@class) to a definition (\@interface).
void startDefinition();
ObjCInterfaceDecl *getSuperClass() const {
@@ -898,8 +902,8 @@
}
/// isObjCRequiresPropertyDefs - Checks that a class or one of its super
- /// classes must not be auto-synthesized. Returns class decl. if it must not be;
- /// 0, otherwise.
+ /// classes must not be auto-synthesized. Returns class decl. if it must not
+ /// be; 0, otherwise.
const ObjCInterfaceDecl *isObjCRequiresPropertyDefs() const {
const ObjCInterfaceDecl *Class = this;
while (Class) {
@@ -947,8 +951,8 @@
SourceLocation getSuperClassLoc() const { return data().SuperClassLoc; }
/// isImplicitInterfaceDecl - check that this is an implicitly declared
- /// ObjCInterfaceDecl node. This is for legacy objective-c @implementation
- /// declaration without an @interface declaration.
+ /// ObjCInterfaceDecl node. This is for legacy objective-c \@implementation
+ /// declaration without an \@interface declaration.
bool isImplicitInterfaceDecl() const {
return hasDefinition() ? Data->Definition->isImplicit() : isImplicit();
}
@@ -991,14 +995,14 @@
/// instance variables are identical to C. The only exception is Objective-C
/// supports C++ style access control. For example:
///
-/// @interface IvarExample : NSObject
+/// \@interface IvarExample : NSObject
/// {
/// id defaultToProtected;
-/// @public:
+/// \@public:
/// id canBePublic; // same as C++.
-/// @protected:
+/// \@protected:
/// id canBeProtected; // same as C++.
-/// @package:
+/// \@package:
/// id canBePackage; // framework visibility (not available in C++).
/// }
///
@@ -1016,7 +1020,7 @@
QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW,
bool synthesized)
: FieldDecl(ObjCIvar, DC, StartLoc, IdLoc, Id, T, TInfo, BW,
- /*Mutable=*/false, /*HasInit=*/false),
+ /*Mutable=*/false, /*HasInit=*/ICIS_NoInit),
NextIvar(0), DeclAccess(ac), Synthesized(synthesized) {}
public:
@@ -1065,8 +1069,7 @@
};
-/// ObjCAtDefsFieldDecl - Represents a field declaration created by an
-/// @defs(...).
+/// \brief Represents a field declaration created by an \@defs(...).
class ObjCAtDefsFieldDecl : public FieldDecl {
virtual void anchor();
ObjCAtDefsFieldDecl(DeclContext *DC, SourceLocation StartLoc,
@@ -1074,7 +1077,7 @@
QualType T, Expr *BW)
: FieldDecl(ObjCAtDefsField, DC, StartLoc, IdLoc, Id, T,
/*TInfo=*/0, // FIXME: Do ObjCAtDefs have declarators ?
- BW, /*Mutable=*/false, /*HasInit=*/false) {}
+ BW, /*Mutable=*/false, /*HasInit=*/ICIS_NoInit) {}
public:
static ObjCAtDefsFieldDecl *Create(ASTContext &C, DeclContext *DC,
@@ -1090,29 +1093,35 @@
static bool classofKind(Kind K) { return K == ObjCAtDefsField; }
};
-/// ObjCProtocolDecl - Represents a protocol declaration. ObjC protocols
-/// declare a pure abstract type (i.e no instance variables are permitted).
-/// Protocols originally drew inspiration from C++ pure virtual functions (a C++
-/// feature with nice semantics and lousy syntax:-). Here is an example:
+/// \brief Represents an Objective-C protocol declaration.
+///
+/// Objective-C protocols declare a pure abstract type (i.e., no instance
+/// variables are permitted). Protocols originally drew inspiration from
+/// C++ pure virtual functions (a C++ feature with nice semantics and lousy
+/// syntax:-). Here is an example:
///
-/// @protocol NSDraggingInfo <refproto1, refproto2>
+/// \code
+/// \@protocol NSDraggingInfo <refproto1, refproto2>
/// - (NSWindow *)draggingDestinationWindow;
/// - (NSImage *)draggedImage;
-/// @end
+/// \@end
+/// \endcode
///
/// This says that NSDraggingInfo requires two methods and requires everything
/// that the two "referenced protocols" 'refproto1' and 'refproto2' require as
/// well.
///
-/// @interface ImplementsNSDraggingInfo : NSObject <NSDraggingInfo>
-/// @end
+/// \code
+/// \@interface ImplementsNSDraggingInfo : NSObject \<NSDraggingInfo>
+/// \@end
+/// \endcode
///
/// ObjC protocols inspired Java interfaces. Unlike Java, ObjC classes and
/// protocols are in distinct namespaces. For example, Cocoa defines both
/// an NSObject protocol and class (which isn't allowed in Java). As a result,
/// protocols are referenced using angle brackets as follows:
///
-/// id <NSDraggingInfo> anyObjectThatImplementsNSDraggingInfo;
+/// id \<NSDraggingInfo> anyObjectThatImplementsNSDraggingInfo;
///
class ObjCProtocolDecl : public ObjCContainerDecl,
public Redeclarable<ObjCProtocolDecl> {
@@ -1274,9 +1283,9 @@
/// you to add instance data. The following example adds "myMethod" to all
/// NSView's within a process:
///
-/// @interface NSView (MyViewMethods)
+/// \@interface NSView (MyViewMethods)
/// - myMethod;
-/// @end
+/// \@end
///
/// Categories also allow you to split the implementation of a class across
/// several files (a feature more naturally supported in C++).
@@ -1450,16 +1459,16 @@
};
/// ObjCCategoryImplDecl - An object of this class encapsulates a category
-/// @implementation declaration. If a category class has declaration of a
+/// \@implementation declaration. If a category class has declaration of a
/// property, its implementation must be specified in the category's
-/// @implementation declaration. Example:
-/// @interface I @end
-/// @interface I(CATEGORY)
-/// @property int p1, d1;
-/// @end
-/// @implementation I(CATEGORY)
-/// @dynamic p1,d1;
-/// @end
+/// \@implementation declaration. Example:
+/// \@interface I \@end
+/// \@interface I(CATEGORY)
+/// \@property int p1, d1;
+/// \@end
+/// \@implementation I(CATEGORY)
+/// \@dynamic p1,d1;
+/// \@end
///
/// ObjCCategoryImplDecl
class ObjCCategoryImplDecl : public ObjCImplDecl {
@@ -1542,9 +1551,9 @@
/// method definitions are specified. For example:
///
/// @code
-/// @implementation MyClass
+/// \@implementation MyClass
/// - (void)myMethod { /* do something */ }
-/// @end
+/// \@end
/// @endcode
///
/// Typically, instance variables are specified in the class interface,
@@ -1556,7 +1565,7 @@
virtual void anchor();
/// Implementation Class's super class.
ObjCInterfaceDecl *SuperClass;
- /// @implementation may have private ivars.
+ /// \@implementation may have private ivars.
SourceLocation IvarLBraceLoc;
SourceLocation IvarRBraceLoc;
@@ -1568,7 +1577,7 @@
/// true if class has a .cxx_[construct,destruct] method.
bool HasCXXStructors : 1;
- /// true of class extension has at least one bitfield ivar.
+ /// true if class extension has at least one bitfield ivar.
bool HasSynthBitfield : 1;
ObjCImplementationDecl(DeclContext *DC,
@@ -1698,7 +1707,7 @@
raw_ostream &operator<<(raw_ostream &OS, const ObjCImplementationDecl &ID);
/// ObjCCompatibleAliasDecl - Represents alias of a class. This alias is
-/// declared as @compatibility_alias alias class.
+/// declared as \@compatibility_alias alias class.
class ObjCCompatibleAliasDecl : public NamedDecl {
virtual void anchor();
/// Class that this is an alias of.
@@ -1725,10 +1734,12 @@
};
-/// ObjCPropertyDecl - Represents one property declaration in an interface.
-/// For example:
-/// @property (assign, readwrite) int MyProperty;
+/// \brief Represents one property declaration in an Objective-C interface.
///
+/// For example:
+/// \code{.mm}
+/// \@property (assign, readwrite) int MyProperty;
+/// \endcode
class ObjCPropertyDecl : public NamedDecl {
virtual void anchor();
public:
@@ -1757,12 +1768,12 @@
enum SetterKind { Assign, Retain, Copy, Weak };
enum PropertyControl { None, Required, Optional };
private:
- SourceLocation AtLoc; // location of @property
+ SourceLocation AtLoc; // location of \@property
SourceLocation LParenLoc; // location of '(' starting attribute list or null.
TypeSourceInfo *DeclType;
unsigned PropertyAttributes : NumPropertyAttrsBits;
unsigned PropertyAttributesAsWritten : NumPropertyAttrsBits;
- // @required/@optional
+ // \@required/\@optional
unsigned PropertyImplementation : 2;
Selector GetterName; // getter name of NULL if no getter
@@ -1874,7 +1885,7 @@
ObjCMethodDecl *getSetterMethodDecl() const { return SetterMethodDecl; }
void setSetterMethodDecl(ObjCMethodDecl *gDecl) { SetterMethodDecl = gDecl; }
- // Related to @optional/@required declared in @protocol
+ // Related to \@optional/\@required declared in \@protocol
void setPropertyImplementation(PropertyControl pc) {
PropertyImplementation = pc;
}
@@ -1904,7 +1915,7 @@
/// ObjCPropertyImplDecl - Represents implementation declaration of a property
/// in a class or category implementation block. For example:
-/// @synthesize prop1 = ivar1;
+/// \@synthesize prop1 = ivar1;
///
class ObjCPropertyImplDecl : public Decl {
public:
@@ -1913,26 +1924,27 @@
Dynamic
};
private:
- SourceLocation AtLoc; // location of @synthesize or @dynamic
+ SourceLocation AtLoc; // location of \@synthesize or \@dynamic
- /// \brief For @synthesize, the location of the ivar, if it was written in
+ /// \brief For \@synthesize, the location of the ivar, if it was written in
/// the source code.
///
/// \code
- /// @synthesize int a = b
+ /// \@synthesize int a = b
/// \endcode
SourceLocation IvarLoc;
/// Property declaration being implemented
ObjCPropertyDecl *PropertyDecl;
- /// Null for @dynamic. Required for @synthesize.
+ /// Null for \@dynamic. Required for \@synthesize.
ObjCIvarDecl *PropertyIvarDecl;
- /// Null for @dynamic. Non-null if property must be copy-constructed in getter
+ /// Null for \@dynamic. Non-null if property must be copy-constructed in
+ /// getter.
Expr *GetterCXXConstructor;
- /// Null for @dynamic. Non-null if property has assignment operator to call
+ /// Null for \@dynamic. Non-null if property has assignment operator to call
/// in Setter synthesis.
Expr *SetterCXXAssignment;
@@ -1982,6 +1994,17 @@
this->IvarLoc = IvarLoc;
}
+ /// \brief For \@synthesize, returns true if an ivar name was explicitly
+ /// specified.
+ ///
+ /// \code
+ /// \@synthesize int a = b; // true
+ /// \@synthesize int a; // false
+ /// \endcode
+ bool isIvarNameSpecified() const {
+ return IvarLoc.isValid() && IvarLoc != getLocation();
+ }
+
Expr *getGetterCXXConstructor() const {
return GetterCXXConstructor;
}
Modified: cfe/branches/tooling/include/clang/AST/EvaluatedExprVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/EvaluatedExprVisitor.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/EvaluatedExprVisitor.h (original)
+++ cfe/branches/tooling/include/clang/AST/EvaluatedExprVisitor.h Fri Jun 15 06:08:27 2012
@@ -24,7 +24,7 @@
class ASTContext;
-/// \begin Given a potentially-evaluated expression, this visitor visits all
+/// \brief Given a potentially-evaluated expression, this visitor visits all
/// of its potentially-evaluated subexpressions, recursively.
template<typename ImplClass>
class EvaluatedExprVisitor : public StmtVisitor<ImplClass> {
Modified: cfe/branches/tooling/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/Expr.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/Expr.h (original)
+++ cfe/branches/tooling/include/clang/AST/Expr.h Fri Jun 15 06:08:27 2012
@@ -225,7 +225,7 @@
/// recursively, any member or element of all contained aggregates or unions)
/// with a const-qualified type.
///
- /// \param Loc [in] [out] - A source location which *may* be filled
+ /// \param Loc [in,out] - A source location which *may* be filled
/// in with the location of the expression making this a
/// non-modifiable lvalue, if specified.
enum isModifiableLvalueResult {
@@ -1385,8 +1385,8 @@
return StringRef(StrData.asChar, getByteLength());
}
- /// Allow clients that need the byte representation, such as ASTWriterStmt
- /// ::VisitStringLiteral(), access.
+ /// Allow access to clients that need the byte representation, such as
+ /// ASTWriterStmt::VisitStringLiteral().
StringRef getBytes() const {
// FIXME: StringRef may not be the right type to use as a result for this.
if (CharByteWidth == 1)
@@ -1399,6 +1399,8 @@
getByteLength());
}
+ void outputString(raw_ostream &OS);
+
uint32_t getCodeUnit(size_t i) const {
assert(i < Length && "out of bounds access");
if (CharByteWidth == 1)
Modified: cfe/branches/tooling/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/ExprCXX.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/ExprCXX.h (original)
+++ cfe/branches/tooling/include/clang/AST/ExprCXX.h Fri Jun 15 06:08:27 2012
@@ -876,7 +876,7 @@
child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
};
-/// CXXConstructExpr - Represents a call to a C++ constructor.
+/// \brief Represents a call to a C++ constructor.
class CXXConstructExpr : public Expr {
public:
enum ConstructionKind {
@@ -1015,9 +1015,13 @@
friend class ASTStmtReader;
};
-/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion
-/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c
-/// x = int(0.5);
+/// \brief Represents an explicit C++ type conversion that uses "functional"
+/// notation (C++ [expr.type.conv]).
+///
+/// Example:
+/// @code
+/// x = int(0.5);
+/// @endcode
class CXXFunctionalCastExpr : public ExplicitCastExpr {
SourceLocation TyBeginLoc;
SourceLocation RParenLoc;
@@ -1436,15 +1440,16 @@
child_range children() { return child_range(); }
};
-/// CXXNewExpr - A new expression for memory allocation and constructor calls,
-/// e.g: "new CXXNewExpr(foo)".
+/// @brief Represents a new-expression for memory allocation and constructor
+// calls, e.g: "new CXXNewExpr(foo)".
class CXXNewExpr : public Expr {
// Contains an optional array size expression, an optional initialization
// expression, and any number of optional placement arguments, in that order.
Stmt **SubExprs;
- // Points to the allocation function used.
+ /// \brief Points to the allocation function used.
FunctionDecl *OperatorNew;
- // Points to the deallocation function used in case of error. May be null.
+ /// \brief Points to the deallocation function used in case of error. May be
+ /// null.
FunctionDecl *OperatorDelete;
/// \brief The allocated type-source information, as written in the source.
@@ -1624,8 +1629,8 @@
}
};
-/// CXXDeleteExpr - A delete expression for memory deallocation and destructor
-/// calls, e.g. "delete[] pArray".
+/// \brief Represents a \c delete expression for memory deallocation and
+/// destructor calls, e.g. "delete[] pArray".
class CXXDeleteExpr : public Expr {
// Points to the operator delete overload that is used. Could be a member.
FunctionDecl *OperatorDelete;
@@ -1695,8 +1700,7 @@
friend class ASTStmtReader;
};
-/// \brief Structure used to store the type being destroyed by a
-/// pseudo-destructor expression.
+/// \brief Stores the type being destroyed by a pseudo-destructor expression.
class PseudoDestructorTypeStorage {
/// \brief Either the type source information or the name of the type, if
/// it couldn't be resolved due to type-dependence.
@@ -1883,11 +1887,14 @@
child_range children() { return child_range(&Base, &Base + 1); }
};
-/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the
-/// implementation of TR1/C++0x type trait templates.
+/// \brief Represents a GCC or MS unary type trait, as used in the
+/// implementation of TR1/C++11 type trait templates.
+///
/// Example:
-/// __is_pod(int) == true
-/// __is_enum(std::string) == false
+/// @code
+/// __is_pod(int) == true
+/// __is_enum(std::string) == false
+/// @endcode
class UnaryTypeTraitExpr : public Expr {
/// UTT - The trait. A UnaryTypeTrait enum in MSVC compat unsigned.
unsigned UTT : 31;
@@ -1938,10 +1945,13 @@
friend class ASTStmtReader;
};
-/// BinaryTypeTraitExpr - A GCC or MS binary type trait, as used in the
-/// implementation of TR1/C++0x type trait templates.
+/// \brief Represents a GCC or MS binary type trait, as used in the
+/// implementation of TR1/C++11 type trait templates.
+///
/// Example:
-/// __is_base_of(Base, Derived) == true
+/// @code
+/// __is_base_of(Base, Derived) == true
+/// @endcode
class BinaryTypeTraitExpr : public Expr {
/// BTT - The trait. A BinaryTypeTrait enum in MSVC compat unsigned.
unsigned BTT : 8;
@@ -2103,30 +2113,33 @@
};
-/// ArrayTypeTraitExpr - An Embarcadero array type trait, as used in the
-/// implementation of __array_rank and __array_extent.
+/// \brief An Embarcadero array type trait, as used in the implementation of
+/// __array_rank and __array_extent.
+///
/// Example:
-/// __array_rank(int[10][20]) == 2
-/// __array_extent(int, 1) == 20
+/// @code
+/// __array_rank(int[10][20]) == 2
+/// __array_extent(int, 1) == 20
+/// @endcode
class ArrayTypeTraitExpr : public Expr {
virtual void anchor();
- /// ATT - The trait. An ArrayTypeTrait enum in MSVC compat unsigned.
+ /// \brief The trait. An ArrayTypeTrait enum in MSVC compat unsigned.
unsigned ATT : 2;
- /// The value of the type trait. Unspecified if dependent.
+ /// \brief The value of the type trait. Unspecified if dependent.
uint64_t Value;
- /// The array dimension being queried, or -1 if not used
+ /// \brief The array dimension being queried, or -1 if not used.
Expr *Dimension;
- /// Loc - The location of the type trait keyword.
+ /// \brief The location of the type trait keyword.
SourceLocation Loc;
- /// RParen - The location of the closing paren.
+ /// \brief The location of the closing paren.
SourceLocation RParen;
- /// The type being queried.
+ /// \brief The type being queried.
TypeSourceInfo *QueriedType;
public:
@@ -2173,22 +2186,26 @@
friend class ASTStmtReader;
};
-/// ExpressionTraitExpr - An expression trait intrinsic
+/// \brief An expression trait intrinsic.
+///
/// Example:
-/// __is_lvalue_expr(std::cout) == true
-/// __is_lvalue_expr(1) == false
+/// @code
+/// __is_lvalue_expr(std::cout) == true
+/// __is_lvalue_expr(1) == false
+/// @endcode
class ExpressionTraitExpr : public Expr {
- /// ET - The trait. A ExpressionTrait enum in MSVC compat unsigned.
+ /// \brief The trait. A ExpressionTrait enum in MSVC compat unsigned.
unsigned ET : 31;
- /// The value of the type trait. Unspecified if dependent.
+ /// \brief The value of the type trait. Unspecified if dependent.
bool Value : 1;
- /// Loc - The location of the type trait keyword.
+ /// \brief The location of the type trait keyword.
SourceLocation Loc;
- /// RParen - The location of the closing paren.
+ /// \brief The location of the closing paren.
SourceLocation RParen;
+ /// \brief The expression being queried.
Expr* QueriedExpression;
public:
ExpressionTraitExpr(SourceLocation loc, ExpressionTrait et,
@@ -2207,7 +2224,9 @@
: Expr(ExpressionTraitExprClass, Empty), ET(0), Value(false),
QueriedExpression() { }
- SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc, RParen);}
+ SourceRange getSourceRange() const LLVM_READONLY {
+ return SourceRange(Loc, RParen);
+ }
ExpressionTrait getTrait() const { return static_cast<ExpressionTrait>(ET); }
@@ -2228,9 +2247,9 @@
/// \brief A reference to an overloaded function set, either an
-/// \t UnresolvedLookupExpr or an \t UnresolvedMemberExpr.
+/// \c UnresolvedLookupExpr or an \c UnresolvedMemberExpr.
class OverloadExpr : public Expr {
- /// The common name of these declarations.
+ /// \brief The common name of these declarations.
DeclarationNameInfo NameInfo;
/// \brief The nested-name-specifier that qualifies the name, if any.
@@ -2309,7 +2328,7 @@
return Result;
}
- /// Gets the naming class of this lookup, if any.
+ /// \brief Gets the naming class of this lookup, if any.
CXXRecordDecl *getNamingClass() const;
typedef UnresolvedSetImpl::iterator decls_iterator;
@@ -2318,25 +2337,25 @@
return UnresolvedSetIterator(Results + NumResults);
}
- /// Gets the number of declarations in the unresolved set.
+ /// \brief Gets the number of declarations in the unresolved set.
unsigned getNumDecls() const { return NumResults; }
- /// Gets the full name info.
+ /// \brief Gets the full name info.
const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
- /// Gets the name looked up.
+ /// \brief Gets the name looked up.
DeclarationName getName() const { return NameInfo.getName(); }
- /// Gets the location of the name.
+ /// \brief Gets the location of the name.
SourceLocation getNameLoc() const { return NameInfo.getLoc(); }
- /// Fetches the nested-name qualifier, if one was given.
+ /// \brief Fetches the nested-name qualifier, if one was given.
NestedNameSpecifier *getQualifier() const {
return QualifierLoc.getNestedNameSpecifier();
}
- /// Fetches the nested-name qualifier with source-location information, if
- /// one was given.
+ /// \brief Fetches the nested-name qualifier with source-location
+ /// information, if one was given.
NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
/// \brief Retrieve the location of the template keyword preceding
@@ -2360,10 +2379,10 @@
return getTemplateKWAndArgsInfo()->RAngleLoc;
}
- /// Determines whether the name was preceded by the template keyword.
+ /// \brief Determines whether the name was preceded by the template keyword.
bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); }
- /// Determines whether this expression had explicit template arguments.
+ /// \brief Determines whether this expression had explicit template arguments.
bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
// Note that, inconsistently with the explicit-template-argument AST
@@ -2387,12 +2406,13 @@
return getExplicitTemplateArgs().NumTemplateArgs;
}
- /// Copies the template arguments into the given structure.
+ /// \brief Copies the template arguments into the given structure.
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
getExplicitTemplateArgs().copyInto(List);
}
/// \brief Retrieves the optional explicit template arguments.
+ ///
/// This points to the same data as getExplicitTemplateArgs(), but
/// returns null if there are no explicit template arguments.
const ASTTemplateArgumentListInfo *getOptionalExplicitTemplateArgs() {
@@ -2411,15 +2431,15 @@
};
/// \brief A reference to a name which we were able to look up during
-/// parsing but could not resolve to a specific declaration. This
-/// arises in several ways:
+/// parsing but could not resolve to a specific declaration.
+///
+/// This arises in several ways:
/// * we might be waiting for argument-dependent lookup
/// * the name might resolve to an overloaded function
/// and eventually:
/// * the lookup might have included a function template
-/// These never include UnresolvedUsingValueDecls, which are always
-/// class members and therefore appear only in
-/// UnresolvedMemberLookupExprs.
+/// These never include UnresolvedUsingValueDecls, which are always class
+/// members and therefore appear only in UnresolvedMemberLookupExprs.
class UnresolvedLookupExpr : public OverloadExpr {
/// True if these lookup results should be extended by
/// argument-dependent lookup if this is the operand of a function
@@ -2761,9 +2781,9 @@
/// type-dependent.
///
/// The explicit type conversions expressed by
-/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN),
-/// where \c T is some type and \c a1, a2, ..., aN are values, and
-/// either \C T is a dependent type or one or more of the \c a's is
+/// CXXUnresolvedConstructExpr have the form <tt>T(a1, a2, ..., aN)<tt>,
+/// where \c T is some type and \c a1, \c a2, ..., \c aN are values, and
+/// either \c T is a dependent type or one or more of the <tt>a</tt>'s is
/// type-dependent. For example, this would occur in a template such
/// as:
///
Modified: cfe/branches/tooling/include/clang/AST/ExprObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/ExprObjC.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/ExprObjC.h (original)
+++ cfe/branches/tooling/include/clang/AST/ExprObjC.h Fri Jun 15 06:08:27 2012
@@ -90,7 +90,7 @@
/// ObjCBoxedExpr - used for generalized expression boxing.
/// as in: @(strdup("hello world")) or @(random())
/// Also used for boxing non-parenthesized numeric literals;
-/// as in: @42 or @true (c++/objc++) or @__yes (c/objc).
+/// as in: @42 or \@true (c++/objc++) or \@__yes (c/objc).
class ObjCBoxedExpr : public Expr {
Stmt *SubExpr;
ObjCMethodDecl *BoxingMethod;
@@ -334,9 +334,9 @@
};
-/// ObjCEncodeExpr, used for @encode in Objective-C. @encode has the same type
-/// and behavior as StringLiteral except that the string initializer is obtained
-/// from ASTContext with the encoding type as an argument.
+/// ObjCEncodeExpr, used for \@encode in Objective-C. \@encode has the same
+/// type and behavior as StringLiteral except that the string initializer is
+/// obtained from ASTContext with the encoding type as an argument.
class ObjCEncodeExpr : public Expr {
TypeSourceInfo *EncodedType;
SourceLocation AtLoc, RParenLoc;
@@ -378,7 +378,7 @@
child_range children() { return child_range(); }
};
-/// ObjCSelectorExpr used for @selector in Objective-C.
+/// ObjCSelectorExpr used for \@selector in Objective-C.
class ObjCSelectorExpr : public Expr {
Selector SelName;
SourceLocation AtLoc, RParenLoc;
@@ -1025,7 +1025,7 @@
/// a l-value or r-value reference will be an l-value or x-value,
/// respectively.
///
- /// \param LBrac The location of the open square bracket '['.
+ /// \param LBracLoc The location of the open square bracket '['.
///
/// \param SuperLoc The location of the "super" keyword.
///
@@ -1039,8 +1039,6 @@
///
/// \param Args The message send arguments.
///
- /// \param NumArgs The number of arguments.
- ///
/// \param RBracLoc The location of the closing square bracket ']'.
static ObjCMessageExpr *Create(ASTContext &Context, QualType T,
ExprValueKind VK,
@@ -1065,7 +1063,7 @@
/// a l-value or r-value reference will be an l-value or x-value,
/// respectively.
///
- /// \param LBrac The location of the open square bracket '['.
+ /// \param LBracLoc The location of the open square bracket '['.
///
/// \param Receiver The type of the receiver, including
/// source-location information.
@@ -1077,8 +1075,6 @@
///
/// \param Args The message send arguments.
///
- /// \param NumArgs The number of arguments.
- ///
/// \param RBracLoc The location of the closing square bracket ']'.
static ObjCMessageExpr *Create(ASTContext &Context, QualType T,
ExprValueKind VK,
@@ -1101,7 +1097,7 @@
/// a l-value or r-value reference will be an l-value or x-value,
/// respectively.
///
- /// \param LBrac The location of the open square bracket '['.
+ /// \param LBracLoc The location of the open square bracket '['.
///
/// \param Receiver The expression used to produce the object that
/// will receive this message.
@@ -1113,8 +1109,6 @@
///
/// \param Args The message send arguments.
///
- /// \param NumArgs The number of arguments.
- ///
/// \param RBracLoc The location of the closing square bracket ']'.
static ObjCMessageExpr *Create(ASTContext &Context, QualType T,
ExprValueKind VK,
Modified: cfe/branches/tooling/include/clang/AST/NSAPI.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/NSAPI.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/NSAPI.h (original)
+++ cfe/branches/tooling/include/clang/AST/NSAPI.h Fri Jun 15 06:08:27 2012
@@ -132,6 +132,11 @@
return getOrInitSelector(Ids, setObjectAtIndexedSubscriptSel);
}
+ /// \brief Returns selector for "isEqual:".
+ Selector getIsEqualSelector() const {
+ return getOrInitSelector(StringRef("isEqual"), isEqualSel);
+ }
+
/// \brief Enumerates the NSNumber methods used to generate literals.
enum NSNumberLiteralMethodKind {
NSNumberWithChar,
@@ -203,7 +208,8 @@
mutable Selector NSNumberInstanceSelectors[NumNSNumberLiteralMethods];
mutable Selector objectForKeyedSubscriptSel, objectAtIndexedSubscriptSel,
- setObjectForKeyedSubscriptSel,setObjectAtIndexedSubscriptSel;
+ setObjectForKeyedSubscriptSel,setObjectAtIndexedSubscriptSel,
+ isEqualSel;
mutable IdentifierInfo *BOOLId, *NSIntegerId, *NSUIntegerId;
mutable IdentifierInfo *NSASCIIStringEncodingId, *NSUTF8StringEncodingId;
Modified: cfe/branches/tooling/include/clang/AST/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/RecursiveASTVisitor.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/branches/tooling/include/clang/AST/RecursiveASTVisitor.h Fri Jun 15 06:08:27 2012
@@ -149,8 +149,8 @@
bool shouldWalkTypesOfTypeLocs() const { return true; }
/// \brief Return whether this visitor should recurse into implicit
- /// declarations, e.g., implicit constructors and destructors.
- bool shouldVisitImplicitDeclarations() const { return false; }
+ /// code, e.g., implicit constructors and destructors.
+ bool shouldVisitImplicitCode() const { return false; }
/// \brief Return whether \param S should be traversed using data recursion
/// to avoid a stack overflow with extreme cases.
@@ -607,7 +607,7 @@
// As a syntax visitor, by default we want to ignore declarations for
// implicit declarations (ones not typed explicitly by the user).
- if (!getDerived().shouldVisitImplicitDeclarations() && D->isImplicit())
+ if (!getDerived().shouldVisitImplicitCode() && D->isImplicit())
return true;
switch (D->getKind()) {
@@ -1755,7 +1755,8 @@
bool RecursiveASTVisitor<Derived>::TraverseVarHelper(VarDecl *D) {
TRY_TO(TraverseDeclaratorHelper(D));
// Default params are taken care of when we traverse the ParmVarDecl.
- if (!isa<ParmVarDecl>(D))
+ if (!isa<ParmVarDecl>(D) &&
+ (!D->isCXXForRangeDecl() || shouldVisitImplicitCode()))
TRY_TO(TraverseStmt(D->getInit()));
return true;
}
@@ -1826,6 +1827,11 @@
// children() iterates over inputExpr and outputExpr.
})
+DEF_TRAVERSE_STMT(MSAsmStmt, {
+ // FIXME: MS Asm doesn't currently parse Constraints, Clobbers, etc. Once
+ // added this needs to be implemented.
+ })
+
DEF_TRAVERSE_STMT(CXXCatchStmt, {
TRY_TO(TraverseDecl(S->getExceptionDecl()));
// children() iterates over the handler block.
@@ -1868,7 +1874,14 @@
DEF_TRAVERSE_STMT(ObjCAtTryStmt, { })
DEF_TRAVERSE_STMT(ObjCForCollectionStmt, { })
DEF_TRAVERSE_STMT(ObjCAutoreleasePoolStmt, { })
-DEF_TRAVERSE_STMT(CXXForRangeStmt, { })
+DEF_TRAVERSE_STMT(CXXForRangeStmt, {
+ if (!shouldVisitImplicitCode()) {
+ TRY_TO(TraverseStmt(S->getLoopVarStmt()));
+ TRY_TO(TraverseStmt(S->getRangeInit()));
+ // Visit everything else only if shouldVisitImplicitCode().
+ return true;
+ }
+})
DEF_TRAVERSE_STMT(MSDependentExistsStmt, {
TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
Modified: cfe/branches/tooling/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/Stmt.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/Stmt.h (original)
+++ cfe/branches/tooling/include/clang/AST/Stmt.h Fri Jun 15 06:08:27 2012
@@ -1606,6 +1606,52 @@
}
};
+/// MSAsmStmt - This represents a MS inline-assembly statement extension.
+///
+class MSAsmStmt : public Stmt {
+ SourceLocation AsmLoc, EndLoc;
+ std::string AsmStr;
+
+ bool IsSimple;
+ bool IsVolatile;
+
+ Stmt **Exprs;
+
+public:
+ MSAsmStmt(ASTContext &C, SourceLocation asmloc, std::string &asmstr,
+ SourceLocation endloc);
+
+ SourceLocation getAsmLoc() const { return AsmLoc; }
+ void setAsmLoc(SourceLocation L) { AsmLoc = L; }
+ SourceLocation getEndLoc() const { return EndLoc; }
+ void setEndLoc(SourceLocation L) { EndLoc = L; }
+
+ bool isVolatile() const { return IsVolatile; }
+ void setVolatile(bool V) { IsVolatile = V; }
+ bool isSimple() const { return IsSimple; }
+ void setSimple(bool V) { IsSimple = V; }
+
+ //===--- Asm String Analysis ---===//
+
+ const std::string *getAsmString() const { return &AsmStr; }
+ std::string *getAsmString() { return &AsmStr; }
+ void setAsmString(StringRef &E) { AsmStr = E.str(); }
+
+ //===--- Other ---===//
+
+ SourceRange getSourceRange() const LLVM_READONLY {
+ return SourceRange(AsmLoc, EndLoc);
+ }
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == MSAsmStmtClass;
+ }
+ static bool classof(const MSAsmStmt *) { return true; }
+
+ child_range children() {
+ return child_range(&Exprs[0], &Exprs[0]);
+ }
+};
+
class SEHExceptStmt : public Stmt {
SourceLocation Loc;
Stmt *Children[2];
Modified: cfe/branches/tooling/include/clang/AST/StmtObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/StmtObjC.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/StmtObjC.h (original)
+++ cfe/branches/tooling/include/clang/AST/StmtObjC.h Fri Jun 15 06:08:27 2012
@@ -6,10 +6,9 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
-// This file defines the Objective-C statement AST node classes.
-//
-//===----------------------------------------------------------------------===//
+
+/// \file
+/// \brief Defines the Objective-C statement AST node classes.
#ifndef LLVM_CLANG_AST_STMTOBJC_H
#define LLVM_CLANG_AST_STMTOBJC_H
@@ -19,9 +18,9 @@
namespace clang {
-/// ObjCForCollectionStmt - This represents Objective-c's collection statement;
-/// represented as 'for (element 'in' collection-expression)' stmt.
+/// \brief Represents Objective-C's collection statement.
///
+/// This is represented as 'for (element 'in' collection-expression)' stmt.
class ObjCForCollectionStmt : public Stmt {
enum { ELEM, COLLECTION, BODY, END_EXPR };
Stmt* SubExprs[END_EXPR]; // SubExprs[ELEM] is an expression or declstmt.
@@ -70,7 +69,7 @@
}
};
-/// ObjCAtCatchStmt - This represents objective-c's @catch statement.
+/// \brief Represents Objective-C's \@catch statement.
class ObjCAtCatchStmt : public Stmt {
private:
VarDecl *ExceptionDecl;
@@ -118,7 +117,7 @@
child_range children() { return child_range(&Body, &Body + 1); }
};
-/// ObjCAtFinallyStmt - This represent objective-c's @finally Statement
+/// \brief Represents Objective-C's \@finally statement
class ObjCAtFinallyStmt : public Stmt {
Stmt *AtFinallyStmt;
SourceLocation AtFinallyLoc;
@@ -151,24 +150,23 @@
}
};
-/// ObjCAtTryStmt - This represent objective-c's over-all
-/// @try ... @catch ... @finally statement.
+/// \brief Represents Objective-C's \@try ... \@catch ... \@finally statement.
class ObjCAtTryStmt : public Stmt {
private:
- // The location of the
+ // The location of the @ in the \@try.
SourceLocation AtTryLoc;
// The number of catch blocks in this statement.
unsigned NumCatchStmts : 16;
- // Whether this statement has a @finally statement.
+ // Whether this statement has a \@finally statement.
bool HasFinally : 1;
- /// \brief Retrieve the statements that are stored after this @try statement.
+ /// \brief Retrieve the statements that are stored after this \@try statement.
///
/// The order of the statements in memory follows the order in the source,
- /// with the @try body first, followed by the @catch statements (if any) and,
- /// finally, the @finally (if it exists).
+ /// with the \@try body first, followed by the \@catch statements (if any)
+ /// and, finally, the \@finally (if it exists).
Stmt **getStmts() { return reinterpret_cast<Stmt **> (this + 1); }
const Stmt* const *getStmts() const {
return reinterpret_cast<const Stmt * const*> (this + 1);
@@ -192,26 +190,26 @@
unsigned NumCatchStmts,
bool HasFinally);
- /// \brief Retrieve the location of the @ in the @try.
+ /// \brief Retrieve the location of the @ in the \@try.
SourceLocation getAtTryLoc() const { return AtTryLoc; }
void setAtTryLoc(SourceLocation Loc) { AtTryLoc = Loc; }
- /// \brief Retrieve the @try body.
+ /// \brief Retrieve the \@try body.
const Stmt *getTryBody() const { return getStmts()[0]; }
Stmt *getTryBody() { return getStmts()[0]; }
void setTryBody(Stmt *S) { getStmts()[0] = S; }
- /// \brief Retrieve the number of @catch statements in this try-catch-finally
+ /// \brief Retrieve the number of \@catch statements in this try-catch-finally
/// block.
unsigned getNumCatchStmts() const { return NumCatchStmts; }
- /// \brief Retrieve a @catch statement.
+ /// \brief Retrieve a \@catch statement.
const ObjCAtCatchStmt *getCatchStmt(unsigned I) const {
assert(I < NumCatchStmts && "Out-of-bounds @catch index");
return cast_or_null<ObjCAtCatchStmt>(getStmts()[I + 1]);
}
- /// \brief Retrieve a @catch statement.
+ /// \brief Retrieve a \@catch statement.
ObjCAtCatchStmt *getCatchStmt(unsigned I) {
assert(I < NumCatchStmts && "Out-of-bounds @catch index");
return cast_or_null<ObjCAtCatchStmt>(getStmts()[I + 1]);
@@ -223,7 +221,7 @@
getStmts()[I + 1] = S;
}
- /// Retrieve the @finally statement, if any.
+ /// \brief Retrieve the \@finally statement, if any.
const ObjCAtFinallyStmt *getFinallyStmt() const {
if (!HasFinally)
return 0;
@@ -254,11 +252,14 @@
}
};
-/// ObjCAtSynchronizedStmt - This is for objective-c's @synchronized statement.
-/// Example: @synchronized (sem) {
-/// do-something;
-/// }
+/// \brief Represents Objective-C's \@synchronized statement.
///
+/// Example:
+/// \code
+/// @synchronized (sem) {
+/// do-something;
+/// }
+/// \endcode
class ObjCAtSynchronizedStmt : public Stmt {
private:
enum { SYNC_EXPR, SYNC_BODY, END_EXPR };
@@ -309,7 +310,7 @@
}
};
-/// ObjCAtThrowStmt - This represents objective-c's @throw statement.
+/// \brief Represents Objective-C's \@throw statement.
class ObjCAtThrowStmt : public Stmt {
Stmt *Throw;
SourceLocation AtThrowLoc;
@@ -343,8 +344,7 @@
child_range children() { return child_range(&Throw, &Throw+1); }
};
-/// ObjCAutoreleasePoolStmt - This represent objective-c's
-/// @autoreleasepool Statement
+/// \brief Represents Objective-C's \@autoreleasepool Statement
class ObjCAutoreleasePoolStmt : public Stmt {
Stmt *SubStmt;
SourceLocation AtLoc;
Modified: cfe/branches/tooling/include/clang/AST/TemplateBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/TemplateBase.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/TemplateBase.h (original)
+++ cfe/branches/tooling/include/clang/AST/TemplateBase.h Fri Jun 15 06:08:27 2012
@@ -73,7 +73,15 @@
union {
uintptr_t TypeOrValue;
struct {
- char Value[sizeof(llvm::APSInt)];
+ // We store a decomposed APSInt with the data allocated by ASTContext if
+ // BitWidth > 64. The memory may be shared between multiple
+ // TemplateArgument instances.
+ union {
+ uint64_t VAL; ///< Used to store the <= 64 bits integer value.
+ const uint64_t *pVal; ///< Used to store the >64 bits integer value.
+ };
+ unsigned BitWidth : 31;
+ unsigned IsUnsigned : 1;
void *Type;
} Integer;
struct {
@@ -104,11 +112,15 @@
TypeOrValue = reinterpret_cast<uintptr_t>(D);
}
- /// \brief Construct an integral constant template argument.
- TemplateArgument(const llvm::APSInt &Value, QualType Type) : Kind(Integral) {
- // FIXME: Large integral values will get leaked. Do something
- // similar to what we did with IntegerLiteral.
- new (Integer.Value) llvm::APSInt(Value);
+ /// \brief Construct an integral constant template argument. The memory to
+ /// store the value is allocated with Ctx.
+ TemplateArgument(ASTContext &Ctx, const llvm::APSInt &Value, QualType Type);
+
+ /// \brief Construct an integral constant template argument with the same
+ /// value as Other but a different type.
+ TemplateArgument(const TemplateArgument &Other, QualType Type)
+ : Kind(Integral) {
+ Integer = Other.Integer;
Integer.Type = Type.getAsOpaquePtr();
}
@@ -165,62 +177,6 @@
this->Args.NumArgs = NumArgs;
}
- /// \brief Copy constructor for a template argument.
- TemplateArgument(const TemplateArgument &Other) : Kind(Other.Kind) {
- // FIXME: Large integral values will get leaked. Do something
- // similar to what we did with IntegerLiteral.
- if (Kind == Integral) {
- new (Integer.Value) llvm::APSInt(*Other.getAsIntegral());
- Integer.Type = Other.Integer.Type;
- } else if (Kind == Pack) {
- Args.NumArgs = Other.Args.NumArgs;
- Args.Args = Other.Args.Args;
- } else if (Kind == Template || Kind == TemplateExpansion) {
- TemplateArg.Name = Other.TemplateArg.Name;
- TemplateArg.NumExpansions = Other.TemplateArg.NumExpansions;
- } else
- TypeOrValue = Other.TypeOrValue;
- }
-
- TemplateArgument& operator=(const TemplateArgument& Other) {
- using llvm::APSInt;
-
- if (Kind == Other.Kind && Kind == Integral) {
- // Copy integral values.
- *this->getAsIntegral() = *Other.getAsIntegral();
- Integer.Type = Other.Integer.Type;
- return *this;
- }
-
- // Destroy the current integral value, if that's what we're holding.
- if (Kind == Integral)
- getAsIntegral()->~APSInt();
-
- Kind = Other.Kind;
-
- if (Other.Kind == Integral) {
- new (Integer.Value) llvm::APSInt(*Other.getAsIntegral());
- Integer.Type = Other.Integer.Type;
- } else if (Other.Kind == Pack) {
- Args.NumArgs = Other.Args.NumArgs;
- Args.Args = Other.Args.Args;
- } else if (Kind == Template || Kind == TemplateExpansion) {
- TemplateArg.Name = Other.TemplateArg.Name;
- TemplateArg.NumExpansions = Other.TemplateArg.NumExpansions;
- } else {
- TypeOrValue = Other.TypeOrValue;
- }
-
- return *this;
- }
-
- ~TemplateArgument() {
- using llvm::APSInt;
-
- if (Kind == Integral)
- getAsIntegral()->~APSInt();
- }
-
/// \brief Create a new template argument pack by copying the given set of
/// template arguments.
static TemplateArgument CreatePackCopy(ASTContext &Context,
@@ -286,14 +242,15 @@
llvm::Optional<unsigned> getNumTemplateExpansions() const;
/// \brief Retrieve the template argument as an integral value.
- llvm::APSInt *getAsIntegral() {
- if (Kind != Integral)
- return 0;
- return reinterpret_cast<llvm::APSInt*>(&Integer.Value[0]);
- }
-
- const llvm::APSInt *getAsIntegral() const {
- return const_cast<TemplateArgument*>(this)->getAsIntegral();
+ // FIXME: Provide a way to read the integral data without copying the value.
+ llvm::APSInt getAsIntegral() const {
+ using namespace llvm;
+ if (Integer.BitWidth <= 64)
+ return APSInt(APInt(Integer.BitWidth, Integer.VAL), Integer.IsUnsigned);
+
+ unsigned NumWords = APInt::getNumWords(Integer.BitWidth);
+ return APSInt(APInt(Integer.BitWidth, makeArrayRef(Integer.pVal, NumWords)),
+ Integer.IsUnsigned);
}
/// \brief Retrieve the type of the integral value.
Modified: cfe/branches/tooling/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/Type.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/Type.h (original)
+++ cfe/branches/tooling/include/clang/AST/Type.h Fri Jun 15 06:08:27 2012
@@ -522,8 +522,6 @@
void setLocalFastQualifiers(unsigned Quals) { Value.setInt(Quals); }
/// Retrieves a pointer to the underlying (unqualified) type.
- /// This should really return a const Type, but it's not worth
- /// changing all the users right now.
///
/// This function requires that the type not be NULL. If the type might be
/// NULL, use the (slightly less efficient) \c getTypePtrOrNull().
@@ -3703,7 +3701,7 @@
unsigned getNumArgs() const { return NumArgs; }
/// \brief Retrieve a specific template argument as a type.
- /// \precondition @c isArgType(Arg)
+ /// \pre @c isArgType(Arg)
const TemplateArgument &getArg(unsigned Idx) const; // in TemplateBase.h
bool isSugared() const {
@@ -4159,8 +4157,10 @@
/// list of protocols.
///
/// Given the following declarations:
-/// @class C;
-/// @protocol P;
+/// \code
+/// \@class C;
+/// \@protocol P;
+/// \endcode
///
/// 'C' is an ObjCInterfaceType C. It is sugar for an ObjCObjectType
/// with base C and no protocols.
@@ -4374,11 +4374,13 @@
/// This method is equivalent to getPointeeType() except that
/// it discards any typedefs (or other sugar) between this
/// type and the "outermost" object type. So for:
- /// @class A; @protocol P; @protocol Q;
+ /// \code
+ /// \@class A; \@protocol P; \@protocol Q;
/// typedef A<P> AP;
/// typedef A A1;
/// typedef A1<P> A1P;
/// typedef A1P<Q> A1PQ;
+ /// \endcode
/// For 'A*', getObjectType() will return 'A'.
/// For 'A<P>*', getObjectType() will return 'A<P>'.
/// For 'AP*', getObjectType() will return 'A<P>'.
@@ -4395,7 +4397,7 @@
}
/// getInterfaceType - If this pointer points to an Objective C
- /// @interface type, gets the type for that interface. Any protocol
+ /// \@interface type, gets the type for that interface. Any protocol
/// qualifiers on the interface are ignored.
///
/// \return null if the base type for this pointer is 'id' or 'Class'
@@ -4403,7 +4405,7 @@
return getObjectType()->getBaseType()->getAs<ObjCInterfaceType>();
}
- /// getInterfaceDecl - If this pointer points to an Objective @interface
+ /// getInterfaceDecl - If this pointer points to an Objective \@interface
/// type, gets the declaration for that interface.
///
/// \return null if the base type for this pointer is 'id' or 'Class'
Modified: cfe/branches/tooling/include/clang/Analysis/Analyses/ThreadSafety.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Analysis/Analyses/ThreadSafety.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Analysis/Analyses/ThreadSafety.h (original)
+++ cfe/branches/tooling/include/clang/Analysis/Analyses/ThreadSafety.h Fri Jun 15 06:08:27 2012
@@ -123,11 +123,11 @@
/// Warn when a protected operation occurs while the specific mutex protecting
/// the operation is not locked.
- /// \param LockName -- A StringRef name for the lock expression, to be printed
- /// in the error message.
/// \param D -- The decl for the protected variable or function
/// \param POK -- The kind of protected operation (e.g. variable access)
- /// \param AK -- The kind of access (i.e. read or write) that occurred
+ /// \param LockName -- A StringRef name for the lock expression, to be printed
+ /// in the error message.
+ /// \param LK -- The kind of access (i.e. read or write) that occurred
/// \param Loc -- The location of the protected operation.
virtual void handleMutexNotHeld(const NamedDecl *D,
ProtectedOperationKind POK, Name LockName,
Modified: cfe/branches/tooling/include/clang/Analysis/CFG.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Analysis/CFG.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Analysis/CFG.h (original)
+++ cfe/branches/tooling/include/clang/Analysis/CFG.h Fri Jun 15 06:08:27 2012
@@ -21,10 +21,10 @@
#include "llvm/Support/Casting.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/BitVector.h"
#include "clang/AST/Stmt.h"
#include "clang/Analysis/Support/BumpVector.h"
#include "clang/Basic/SourceLocation.h"
+#include <bitset>
#include <cassert>
#include <iterator>
@@ -559,7 +559,7 @@
//===--------------------------------------------------------------------===//
class BuildOptions {
- llvm::BitVector alwaysAddMask;
+ std::bitset<Stmt::lastStmtConstant> alwaysAddMask;
public:
typedef llvm::DenseMap<const Stmt *, const CFGBlock*> ForcedBlkExprs;
ForcedBlkExprs **forcedBlkExprs;
@@ -584,8 +584,7 @@
}
BuildOptions()
- : alwaysAddMask(Stmt::lastStmtConstant, false)
- ,forcedBlkExprs(0), PruneTriviallyFalseEdges(true)
+ : forcedBlkExprs(0), PruneTriviallyFalseEdges(true)
,AddEHEdges(false)
,AddInitializers(false)
,AddImplicitDtors(false) {}
Modified: cfe/branches/tooling/include/clang/Analysis/CallGraph.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Analysis/CallGraph.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Analysis/CallGraph.h (original)
+++ cfe/branches/tooling/include/clang/Analysis/CallGraph.h Fri Jun 15 06:08:27 2012
@@ -26,7 +26,7 @@
namespace clang {
class CallGraphNode;
-/// \class The AST-based call graph.
+/// \brief The AST-based call graph.
///
/// The call graph extends itself with the given declarations by implementing
/// the recursive AST visitor, which constructs the graph by visiting the given
Modified: cfe/branches/tooling/include/clang/Analysis/ProgramPoint.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Analysis/ProgramPoint.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Analysis/ProgramPoint.h (original)
+++ cfe/branches/tooling/include/clang/Analysis/ProgramPoint.h Fri Jun 15 06:08:27 2012
@@ -314,7 +314,7 @@
}
};
-/// \class Represents a program point after a store evaluation.
+/// \brief Represents a program point after a store evaluation.
class PostStore : public PostStmt {
public:
/// Construct the post store point.
@@ -350,7 +350,7 @@
}
};
-/// \class Represents a point after we ran remove dead bindings BEFORE
+/// Represents a point after we ran remove dead bindings BEFORE
/// processing the given statement.
class PreStmtPurgeDeadSymbols : public StmtPoint {
public:
@@ -363,7 +363,7 @@
}
};
-/// \class Represents a point after we ran remove dead bindings AFTER
+/// Represents a point after we ran remove dead bindings AFTER
/// processing the given statement.
class PostStmtPurgeDeadSymbols : public StmtPoint {
public:
@@ -408,7 +408,7 @@
}
};
-/// \class Represents a point when we begin processing an inlined call.
+/// Represents a point when we begin processing an inlined call.
class CallEnter : public StmtPoint {
public:
CallEnter(const Stmt *stmt, const StackFrameContext *calleeCtx,
@@ -428,8 +428,7 @@
}
};
-/// \class Represents a point when we start the call exit sequence (for
-/// inlined call).
+/// Represents a point when we start the call exit sequence (for inlined call).
///
/// The call exit is simulated with a sequence of nodes, which occur between
/// CallExitBegin and CallExitEnd. The following operations occur between the
@@ -449,8 +448,7 @@
}
};
-/// \class Represents a point when we finish the call exit sequence (for
-/// inlined call).
+/// Represents a point when we finish the call exit sequence (for inlined call).
/// \sa CallExitBegin
class CallExitEnd : public StmtPoint {
public:
Modified: cfe/branches/tooling/include/clang/Basic/Builtins.def
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/Builtins.def?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/Builtins.def (original)
+++ cfe/branches/tooling/include/clang/Basic/Builtins.def Fri Jun 15 06:08:27 2012
@@ -33,7 +33,8 @@
// H -> SEL
// a -> __builtin_va_list
// A -> "reference" to __builtin_va_list
-// V -> Vector, following num elements and a base type.
+// V -> Vector, followed by the number of elements and the base type.
+// E -> ext_vector, followed by the number of elements and the base type.
// X -> _Complex, followed by the base type.
// Y -> ptrdiff_t
// P -> FILE
Modified: cfe/branches/tooling/include/clang/Basic/BuiltinsX86.def
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/BuiltinsX86.def?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/branches/tooling/include/clang/Basic/BuiltinsX86.def Fri Jun 15 06:08:27 2012
@@ -641,4 +641,71 @@
BUILTIN(__builtin_ia32_vfmsubaddps256, "V8fV8fV8fV8f", "")
BUILTIN(__builtin_ia32_vfmsubaddpd256, "V4dV4dV4dV4d", "")
+// XOP
+BUILTIN(__builtin_ia32_vpmacssww, "V8sV8sV8sV8s", "")
+BUILTIN(__builtin_ia32_vpmacsww, "V8sV8sV8sV8s", "")
+BUILTIN(__builtin_ia32_vpmacsswd, "V4iV8sV8sV4i", "")
+BUILTIN(__builtin_ia32_vpmacswd, "V4iV8sV8sV4i", "")
+BUILTIN(__builtin_ia32_vpmacssdd, "V4iV4iV4iV4i", "")
+BUILTIN(__builtin_ia32_vpmacsdd, "V4iV4iV4iV4i", "")
+BUILTIN(__builtin_ia32_vpmacssdql, "V2LLiV4iV4iV2LLi", "")
+BUILTIN(__builtin_ia32_vpmacsdql, "V2LLiV4iV4iV2LLi", "")
+BUILTIN(__builtin_ia32_vpmacssdqh, "V2LLiV4iV4iV2LLi", "")
+BUILTIN(__builtin_ia32_vpmacsdqh, "V2LLiV4iV4iV2LLi", "")
+BUILTIN(__builtin_ia32_vpmadcsswd, "V4iV8sV8sV4i", "")
+BUILTIN(__builtin_ia32_vpmadcswd, "V4iV8sV8sV4i", "")
+
+BUILTIN(__builtin_ia32_vphaddbw, "V8sV16c", "")
+BUILTIN(__builtin_ia32_vphaddbd, "V4iV16c", "")
+BUILTIN(__builtin_ia32_vphaddbq, "V2LLiV16c", "")
+BUILTIN(__builtin_ia32_vphaddwd, "V4iV8s", "")
+BUILTIN(__builtin_ia32_vphaddwq, "V2LLiV8s", "")
+BUILTIN(__builtin_ia32_vphadddq, "V2LLiV4i", "")
+BUILTIN(__builtin_ia32_vphaddubw, "V8sV16c", "")
+BUILTIN(__builtin_ia32_vphaddubd, "V4iV16c", "")
+BUILTIN(__builtin_ia32_vphaddubq, "V2LLiV16c", "")
+BUILTIN(__builtin_ia32_vphadduwd, "V4iV8s", "")
+BUILTIN(__builtin_ia32_vphadduwq, "V2LLiV8s", "")
+BUILTIN(__builtin_ia32_vphaddudq, "V2LLiV4i", "")
+BUILTIN(__builtin_ia32_vphsubbw, "V8sV16c", "")
+BUILTIN(__builtin_ia32_vphsubwd, "V4iV8s", "")
+BUILTIN(__builtin_ia32_vphsubdq, "V2LLiV4i", "")
+BUILTIN(__builtin_ia32_vpcmov, "V2LLiV2LLiV2LLiV2LLi", "")
+BUILTIN(__builtin_ia32_vpcmov_256, "V4LLiV4LLiV4LLiV4LLi", "")
+BUILTIN(__builtin_ia32_vpperm, "V16cV16cV16cV16c", "")
+BUILTIN(__builtin_ia32_vprotb, "V16cV16cV16c", "")
+BUILTIN(__builtin_ia32_vprotw, "V8sV8sV8s", "")
+BUILTIN(__builtin_ia32_vprotd, "V4iV4iV4i", "")
+BUILTIN(__builtin_ia32_vprotq, "V2LLiV2LLiV2LLi", "")
+BUILTIN(__builtin_ia32_vprotbi, "V16cV16cIc", "")
+BUILTIN(__builtin_ia32_vprotwi, "V8sV8sIc", "")
+BUILTIN(__builtin_ia32_vprotdi, "V4iV4iIc", "")
+BUILTIN(__builtin_ia32_vprotqi, "V2LLiV2LLiIc", "")
+BUILTIN(__builtin_ia32_vpshlb, "V16cV16cV16c", "")
+BUILTIN(__builtin_ia32_vpshlw, "V8sV8sV8s", "")
+BUILTIN(__builtin_ia32_vpshld, "V4iV4iV4i", "")
+BUILTIN(__builtin_ia32_vpshlq, "V2LLiV2LLiV2LLi", "")
+BUILTIN(__builtin_ia32_vpshab, "V16cV16cV16c", "")
+BUILTIN(__builtin_ia32_vpshaw, "V8sV8sV8s", "")
+BUILTIN(__builtin_ia32_vpshad, "V4iV4iV4i", "")
+BUILTIN(__builtin_ia32_vpshaq, "V2LLiV2LLiV2LLi", "")
+BUILTIN(__builtin_ia32_vpcomub, "V16cV16cV16cIc", "")
+BUILTIN(__builtin_ia32_vpcomuw, "V8sV8sV8sIc", "")
+BUILTIN(__builtin_ia32_vpcomud, "V4iV4iV4iIc", "")
+BUILTIN(__builtin_ia32_vpcomuq, "V2LLiV2LLiV2LLiIc", "")
+BUILTIN(__builtin_ia32_vpcomb, "V16cV16cV16cIc", "")
+BUILTIN(__builtin_ia32_vpcomw, "V8sV8sV8sIc", "")
+BUILTIN(__builtin_ia32_vpcomd, "V4iV4iV4iIc", "")
+BUILTIN(__builtin_ia32_vpcomq, "V2LLiV2LLiV2LLiIc", "")
+BUILTIN(__builtin_ia32_vpermil2pd, "V2dV2dV2dV2LLiIc", "")
+BUILTIN(__builtin_ia32_vpermil2pd256, "V4dV4dV4dV4LLiIc", "")
+BUILTIN(__builtin_ia32_vpermil2ps, "V4fV4fV4fV4iIc", "")
+BUILTIN(__builtin_ia32_vpermil2ps256, "V8fV8fV8fV8iIc", "")
+BUILTIN(__builtin_ia32_vfrczss, "V4fV4f", "")
+BUILTIN(__builtin_ia32_vfrczsd, "V2dV2d", "")
+BUILTIN(__builtin_ia32_vfrczps, "V4fV4f", "")
+BUILTIN(__builtin_ia32_vfrczpd, "V2dV2d", "")
+BUILTIN(__builtin_ia32_vfrczps256, "V8fV8f", "")
+BUILTIN(__builtin_ia32_vfrczpd256, "V4dV4d", "")
+
#undef BUILTIN
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=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td Fri Jun 15 06:08:27 2012
@@ -312,7 +312,7 @@
[UnusedArgument, UnusedFunction, UnusedLabel,
// UnusedParameter, (matches GCC's behavior)
// UnusedMemberFunction, (clean-up llvm before enabling)
- // UnusedPrivateField, (clean-up llvm before enabling)
+ UnusedPrivateField,
UnusedValue, UnusedVariable]>,
DiagCategory<"Unused Entity Issue">;
Modified: cfe/branches/tooling/include/clang/Basic/DiagnosticIDs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/DiagnosticIDs.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticIDs.h (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticIDs.h Fri Jun 15 06:08:27 2012
@@ -63,10 +63,10 @@
/// one).
enum Mapping {
// NOTE: 0 means "uncomputed".
- MAP_IGNORE = 1, //< Map this diagnostic to nothing, ignore it.
- MAP_WARNING = 2, //< Map this diagnostic to a warning.
- MAP_ERROR = 3, //< Map this diagnostic to an error.
- MAP_FATAL = 4 //< Map this diagnostic to a fatal error.
+ MAP_IGNORE = 1, ///< Map this diagnostic to nothing, ignore it.
+ MAP_WARNING = 2, ///< Map this diagnostic to a warning.
+ MAP_ERROR = 3, ///< Map this diagnostic to an error.
+ MAP_FATAL = 4 ///< Map this diagnostic to a fatal error.
};
}
Modified: cfe/branches/tooling/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/DiagnosticParseKinds.td?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticParseKinds.td Fri Jun 15 06:08:27 2012
@@ -20,7 +20,9 @@
let CategoryName = "Parse Issue" in {
-def ext_empty_source_file : Extension<"ISO C forbids an empty source file">;
+def ext_empty_translation_unit : Extension<
+ "ISO C requires a translation unit to contain at least one declaration.">,
+ InGroup<DiagGroup<"empty-translation-unit">>;
def warn_cxx98_compat_top_level_semi : Warning<
"extra ';' outside of a function is incompatible with C++98">,
InGroup<CXX98CompatPedantic>, DefaultIgnore;
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=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td Fri Jun 15 06:08:27 2012
@@ -1469,6 +1469,10 @@
// Objective-C++
def err_objc_decls_may_only_appear_in_global_scope : Error<
"Objective-C declarations may only appear in global scope">;
+def warn_auto_var_is_id : Warning<
+ "'auto' deduced as 'id' in declaration of %0">,
+ InGroup<DiagGroup<"auto-var-id">>;
+
// Attributes
def err_nsobject_attribute : Error<
"__attribute ((NSObject)) is for pointer types only">;
@@ -1593,6 +1597,10 @@
def err_box_literal_collection : Error<
"%select{string|character|boolean|numeric}0 literal must be prefixed by '@' "
"in a collection">;
+def err_objc_literal_comparison : Error<
+ "direct comparison of %select{a string literal|an array literal|"
+ "a dictionary literal|a numeric literal|a boxed expression|}0 is not "
+ "allowed%select{|; use -isEqual: instead}1">;
let CategoryName = "Cocoa API Issue" in {
def warn_objc_redundant_literal_use : Warning<
Modified: cfe/branches/tooling/include/clang/Basic/FileSystemStatCache.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/FileSystemStatCache.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/FileSystemStatCache.h (original)
+++ cfe/branches/tooling/include/clang/Basic/FileSystemStatCache.h Fri Jun 15 06:08:27 2012
@@ -34,8 +34,8 @@
virtual ~FileSystemStatCache() {}
enum LookupResult {
- CacheExists, //< We know the file exists and its cached stat data.
- CacheMissing //< We know that the file doesn't exist.
+ CacheExists, ///< We know the file exists and its cached stat data.
+ CacheMissing ///< We know that the file doesn't exist.
};
/// FileSystemStatCache::get - Get the 'stat' information for the specified
Modified: cfe/branches/tooling/include/clang/Basic/IdentifierTable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/IdentifierTable.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/IdentifierTable.h (original)
+++ cfe/branches/tooling/include/clang/Basic/IdentifierTable.h Fri Jun 15 06:08:27 2012
@@ -42,7 +42,7 @@
/// IdentifierInfo - One of these records is kept for each identifier that
-/// is lexed. This contains information about whether the token was #define'd,
+/// is lexed. This contains information about whether the token was \#define'd,
/// is a language keyword, or if it is a front-end token of some sort (e.g. a
/// variable or function name). The preprocessor keeps this information in a
/// set, and all tok::identifier tokens have a pointer to one of these.
@@ -67,7 +67,7 @@
bool OutOfDate : 1; // True if there may be additional
// information about this identifier
// stored externally.
- bool IsModulesImport : 1; // True if this is the 'import' contextual
+ bool IsModulesImport : 1; // True if this is the 'import' contextual
// keyword.
// 1 bit left in 32-bit word.
@@ -83,15 +83,16 @@
IdentifierInfo();
- /// isStr - Return true if this is the identifier for the specified string.
+ /// \brief Return true if this is the identifier for the specified string.
+ ///
/// This is intended to be used for string literals only: II->isStr("foo").
template <std::size_t StrLen>
bool isStr(const char (&Str)[StrLen]) const {
return getLength() == StrLen-1 && !memcmp(getNameStart(), Str, StrLen-1);
}
- /// getNameStart - Return the beginning of the actual string for this
- /// identifier. The returned string is properly null terminated.
+ /// \brief Return the beginning of the actual null-terminated string for this
+ /// identifier.
///
const char *getNameStart() const {
if (Entry) return Entry->getKeyData();
@@ -104,7 +105,7 @@
return ((const actualtype*) this)->second;
}
- /// getLength - Efficiently return the length of this identifier info.
+ /// \brief Efficiently return the length of this identifier info.
///
unsigned getLength() const {
if (Entry) return Entry->getKeyLength();
@@ -118,13 +119,12 @@
return (((unsigned) p[0]) | (((unsigned) p[1]) << 8)) - 1;
}
- /// getName - Return the actual identifier string.
+ /// \brief Return the actual identifier string.
StringRef getName() const {
return StringRef(getNameStart(), getLength());
}
- /// hasMacroDefinition - Return true if this identifier is #defined to some
- /// other value.
+ /// \brief Return true if this identifier is \#defined to some other value.
bool hasMacroDefinition() const {
return HasMacro;
}
@@ -158,13 +158,14 @@
RevertedTokenID = true;
}
- /// getPPKeywordID - Return the preprocessor keyword ID for this identifier.
+ /// \brief Return the preprocessor keyword ID for this identifier.
+ ///
/// For example, "define" will return tok::pp_define.
tok::PPKeywordKind getPPKeywordID() const;
- /// getObjCKeywordID - Return the Objective-C keyword ID for the this
- /// identifier. For example, 'class' will return tok::objc_class if ObjC is
- /// enabled.
+ /// \brief Return the Objective-C keyword ID for the this identifier.
+ ///
+ /// For example, 'class' will return tok::objc_class if ObjC is enabled.
tok::ObjCKeywordKind getObjCKeywordID() const {
if (ObjCOrBuiltinID < tok::NUM_OBJC_KEYWORDS)
return tok::ObjCKeywordKind(ObjCOrBuiltinID);
Modified: cfe/branches/tooling/include/clang/Basic/MacroBuilder.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/MacroBuilder.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/MacroBuilder.h (original)
+++ cfe/branches/tooling/include/clang/Basic/MacroBuilder.h Fri Jun 15 06:08:27 2012
@@ -24,7 +24,7 @@
public:
MacroBuilder(raw_ostream &Output) : Out(Output) {}
- /// Append a #define line for macro of the form "#define Name Value\n".
+ /// Append a \#define line for macro of the form "\#define Name Value\n".
void defineMacro(const Twine &Name, const Twine &Value = "1") {
Out << "#define " << Name << ' ' << Value << '\n';
}
Modified: cfe/branches/tooling/include/clang/Basic/OperatorKinds.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/OperatorKinds.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/OperatorKinds.h (original)
+++ cfe/branches/tooling/include/clang/Basic/OperatorKinds.h Fri Jun 15 06:08:27 2012
@@ -19,7 +19,7 @@
/// OverloadedOperatorKind - Enumeration specifying the different kinds of
/// C++ overloaded operators.
enum OverloadedOperatorKind {
- OO_None, //< Not an overloaded operator
+ OO_None, ///< Not an overloaded operator
#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
OO_##Name,
#include "clang/Basic/OperatorKinds.def"
Modified: cfe/branches/tooling/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/SourceManager.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/SourceManager.h (original)
+++ cfe/branches/tooling/include/clang/Basic/SourceManager.h Fri Jun 15 06:08:27 2012
@@ -584,6 +584,9 @@
/// \brief The file ID for the precompiled preamble there is one.
FileID PreambleFileID;
+ /// \brief The file ID for the preprocessor's predefines.
+ FileID PredefinesFileID;
+
// Statistics for -print-stats.
mutable unsigned NumLinearScans, NumBinaryProbes;
@@ -628,6 +631,14 @@
MainFileID = createFileIDForMemBuffer(Buffer);
return MainFileID;
}
+
+ /// \brief Create the FileID for a memory buffer that contains the
+ /// preprocessor's predefines.
+ FileID createPredefinesFileIDForMemBuffer(const llvm::MemoryBuffer *Buffer) {
+ assert(PredefinesFileID.isInvalid() && "PredefinesFileID already set!");
+ PredefinesFileID = createFileIDForMemBuffer(Buffer);
+ return PredefinesFileID;
+ }
//===--------------------------------------------------------------------===//
// MainFileID creation and querying methods.
@@ -636,6 +647,9 @@
/// getMainFileID - Returns the FileID of the main source file.
FileID getMainFileID() const { return MainFileID; }
+ /// \brief Returns the FileID of the preprocessor predefines buffer.
+ FileID getPredefinesFileID() const { return PredefinesFileID; }
+
/// createMainFileID - Create the FileID for the main source file.
FileID createMainFileID(const FileEntry *SourceFile,
SrcMgr::CharacteristicKind Kind = SrcMgr::C_User) {
@@ -881,7 +895,7 @@
return SourceLocation::getFileLoc(FileOffset + getFileIDSize(FID) - 1);
}
- /// \brief Returns the include location if \p FID is a #include'd file
+ /// \brief Returns the include location if \p FID is a \#include'd file
/// otherwise it returns an invalid location.
SourceLocation getIncludeLoc(FileID FID) const {
bool Invalid = false;
@@ -1113,6 +1127,12 @@
return getFileID(Loc) == getMainFileID();
}
+ /// isFromPredefines - Returns true if the provided SourceLocation is
+ /// within the processor's predefines buffer.
+ bool isFromPredefines(SourceLocation Loc) const {
+ return getFileID(Loc) == getPredefinesFileID();
+ }
+
/// isInSystemHeader - Returns if a SourceLocation is in a system header.
bool isInSystemHeader(SourceLocation Loc) const {
return getFileCharacteristic(Loc) != SrcMgr::C_User;
Modified: cfe/branches/tooling/include/clang/Basic/SourceManagerInternals.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/SourceManagerInternals.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/SourceManagerInternals.h (original)
+++ cfe/branches/tooling/include/clang/Basic/SourceManagerInternals.h Fri Jun 15 06:08:27 2012
@@ -15,6 +15,7 @@
#ifndef LLVM_CLANG_SOURCEMANAGER_INTERNALS_H
#define LLVM_CLANG_SOURCEMANAGER_INTERNALS_H
+#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "llvm/ADT/StringMap.h"
#include <map>
@@ -29,11 +30,11 @@
/// FileOffset - The offset in this file that the line entry occurs at.
unsigned FileOffset;
- /// LineNo - The presumed line number of this line entry: #line 4.
+ /// LineNo - The presumed line number of this line entry: \#line 4.
unsigned LineNo;
/// FilenameID - The ID of the filename identified by this line entry:
- /// #line 4 "foo.c". This is -1 if not specified.
+ /// \#line 4 "foo.c". This is -1 if not specified.
int FilenameID;
/// Flags - Set the 0 if no flags, 1 if a system header,
@@ -84,7 +85,7 @@
/// LineEntries - This is a map from FileIDs to a list of line entries (sorted
/// by the offset they occur in the file.
- std::map<int, std::vector<LineEntry> > LineEntries;
+ std::map<FileID, std::vector<LineEntry> > LineEntries;
public:
LineTableInfo() {
}
@@ -104,25 +105,25 @@
}
unsigned getNumFilenames() const { return FilenamesByID.size(); }
- void AddLineNote(int FID, unsigned Offset,
+ void AddLineNote(FileID FID, unsigned Offset,
unsigned LineNo, int FilenameID);
- void AddLineNote(int FID, unsigned Offset,
+ void AddLineNote(FileID FID, unsigned Offset,
unsigned LineNo, int FilenameID,
unsigned EntryExit, SrcMgr::CharacteristicKind FileKind);
/// FindNearestLineEntry - Find the line entry nearest to FID that is before
/// it. If there is no line entry before Offset in FID, return null.
- const LineEntry *FindNearestLineEntry(int FID, unsigned Offset);
+ const LineEntry *FindNearestLineEntry(FileID FID, unsigned Offset);
// Low-level access
- typedef std::map<int, std::vector<LineEntry> >::iterator iterator;
+ typedef std::map<FileID, std::vector<LineEntry> >::iterator iterator;
iterator begin() { return LineEntries.begin(); }
iterator end() { return LineEntries.end(); }
/// \brief Add a new line entry that has already been encoded into
/// the internal representation of the line table.
- void AddEntry(int FID, const std::vector<LineEntry> &Entries);
+ void AddEntry(FileID FID, const std::vector<LineEntry> &Entries);
};
} // end namespace clang
Modified: cfe/branches/tooling/include/clang/Basic/Specifiers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/Specifiers.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/Specifiers.h (original)
+++ cfe/branches/tooling/include/clang/Basic/Specifiers.h Fri Jun 15 06:08:27 2012
@@ -168,6 +168,13 @@
inline bool isLegalForVariable(StorageClass SC) {
return true;
}
+
+ /// \brief In-class initialization styles for non-static data members.
+ enum InClassInitStyle {
+ ICIS_NoInit, ///< No in-class initializer.
+ ICIS_CopyInit, ///< Copy initialization.
+ ICIS_ListInit ///< Direct list-initialization.
+ };
} // end namespace clang
#endif // LLVM_CLANG_BASIC_SPECIFIERS_H
Modified: cfe/branches/tooling/include/clang/Basic/StmtNodes.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/StmtNodes.td?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/StmtNodes.td (original)
+++ cfe/branches/tooling/include/clang/Basic/StmtNodes.td Fri Jun 15 06:08:27 2012
@@ -31,6 +31,9 @@
// GNU Extensions
def AsmStmt : Stmt;
+// MS Extensions
+def MSAsmStmt : Stmt;
+
// Obj-C statements
def ObjCAtTryStmt : Stmt;
def ObjCAtCatchStmt : Stmt;
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=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Driver/CC1Options.td (original)
+++ cfe/branches/tooling/include/clang/Driver/CC1Options.td Fri Jun 15 06:08:27 2012
@@ -469,6 +469,14 @@
"implicit extern \"C\" semantics; these are assumed to not be "
"user-provided and are used to model system and standard headers' "
"paths.">;
+def isystem_prefix : JoinedOrSeparate<"-isystem-prefix">,
+ MetaVarName<"<prefix>">,
+ HelpText<"Treat all #include paths starting with <prefix> as including a "
+ "system header.">;
+def ino_system_prefix : JoinedOrSeparate<"-ino-system-prefix">,
+ MetaVarName<"<prefix>">,
+ HelpText<"Treat all #include paths starting with <prefix> as not including a "
+ "system header.">;
//===----------------------------------------------------------------------===//
// Preprocessor Options
Modified: cfe/branches/tooling/include/clang/Driver/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Driver/Makefile?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Driver/Makefile (original)
+++ cfe/branches/tooling/include/clang/Driver/Makefile Fri Jun 15 06:08:27 2012
@@ -5,7 +5,7 @@
include $(CLANG_LEVEL)/Makefile
-$(ObjDir)/Options.inc.tmp : Options.td OptParser.td $(CLANG_TBLGEN) $(ObjDir)/.dir
+$(ObjDir)/Options.inc.tmp : Options.td CC1Options.td OptParser.td $(CLANG_TBLGEN) $(ObjDir)/.dir
$(Echo) "Building Clang Driver Option tables with tblgen"
$(Verb) $(ClangTableGen) -gen-opt-parser-defs -o $(call SYSPATH, $@) $<
Modified: cfe/branches/tooling/include/clang/Driver/OptTable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Driver/OptTable.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Driver/OptTable.h (original)
+++ cfe/branches/tooling/include/clang/Driver/OptTable.h Fri Jun 15 06:08:27 2012
@@ -35,7 +35,7 @@
class InputArgList;
class Option;
- /// OptTable - Provide access to the Option info table.
+ /// \brief Provide access to the Option info table.
///
/// The OptTable class provides a layer of indirection which allows Option
/// instance to be created lazily. In the common case, only a few options will
@@ -44,7 +44,7 @@
/// parts of the driver still use Option instances where convenient.
class OptTable {
public:
- /// Info - Entry for a single option instance in the option data table.
+ /// \brief Entry for a single option instance in the option data table.
struct Info {
const char *Name;
const char *HelpText;
@@ -57,17 +57,17 @@
};
private:
- /// The static option information table.
+ /// \brief The static option information table.
const Info *OptionInfos;
unsigned NumOptionInfos;
- /// The lazily constructed options table, indexed by option::ID - 1.
+ /// \brief The lazily constructed options table, indexed by option::ID - 1.
mutable Option **Options;
- /// Prebound input option instance.
+ /// \brief Prebound input option instance.
const Option *TheInputOption;
- /// Prebound unknown option instance.
+ /// \brief Prebound unknown option instance.
const Option *TheUnknownOption;
/// The index of the first option which can be parsed (i.e., is not a
@@ -88,10 +88,10 @@
public:
~OptTable();
- /// getNumOptions - Return the total number of option classes.
+ /// \brief Return the total number of option classes.
unsigned getNumOptions() const { return NumOptionInfos; }
- /// getOption - Get the given \arg id's Option instance, lazily creating it
+ /// \brief Get the given Opt's Option instance, lazily creating it
/// if necessary.
///
/// \return The option, or null for the INVALID option id.
@@ -107,72 +107,71 @@
return Entry;
}
- /// getOptionName - Lookup the name of the given option.
+ /// \brief Lookup the name of the given option.
const char *getOptionName(OptSpecifier id) const {
return getInfo(id).Name;
}
- /// getOptionKind - Get the kind of the given option.
+ /// \brief Get the kind of the given option.
unsigned getOptionKind(OptSpecifier id) const {
return getInfo(id).Kind;
}
- /// getOptionGroupID - Get the group id for the given option.
+ /// \brief Get the group id for the given option.
unsigned getOptionGroupID(OptSpecifier id) const {
return getInfo(id).GroupID;
}
- /// isOptionHelpHidden - Should the help for the given option be hidden by
- /// default.
+ /// \brief Should the help for the given option be hidden by default.
bool isOptionHelpHidden(OptSpecifier id) const {
return getInfo(id).Flags & options::HelpHidden;
}
- /// getOptionHelpText - Get the help text to use to describe this option.
+ /// \brief Get the help text to use to describe this option.
const char *getOptionHelpText(OptSpecifier id) const {
return getInfo(id).HelpText;
}
- /// getOptionMetaVar - Get the meta-variable name to use when describing
+ /// \brief Get the meta-variable name to use when describing
/// this options values in the help text.
const char *getOptionMetaVar(OptSpecifier id) const {
return getInfo(id).MetaVar;
}
- /// ParseOneArg - Parse a single argument; returning the new argument and
+ /// \brief Parse a single argument; returning the new argument and
/// updating Index.
///
- /// \param [in] [out] Index - The current parsing position in the argument
+ /// \param [in,out] Index - The current parsing position in the argument
/// string list; on return this will be the index of the next argument
/// string to parse.
///
- /// \return - The parsed argument, or 0 if the argument is missing values
+ /// \return The parsed argument, or 0 if the argument is missing values
/// (in which case Index still points at the conceptual next argument string
/// to parse).
Arg *ParseOneArg(const ArgList &Args, unsigned &Index) const;
- /// ParseArgs - Parse an list of arguments into an InputArgList.
+ /// \brief Parse an list of arguments into an InputArgList.
///
- /// The resulting InputArgList will reference the strings in [ArgBegin,
- /// ArgEnd), and their lifetime should extend past that of the returned
+ /// The resulting InputArgList will reference the strings in [\p ArgBegin,
+ /// \p ArgEnd), and their lifetime should extend past that of the returned
/// InputArgList.
///
/// The only error that can occur in this routine is if an argument is
- /// missing values; in this case \arg MissingArgCount will be non-zero.
+ /// missing values; in this case \p MissingArgCount will be non-zero.
///
/// \param ArgBegin - The beginning of the argument vector.
/// \param ArgEnd - The end of the argument vector.
/// \param MissingArgIndex - On error, the index of the option which could
/// not be parsed.
/// \param MissingArgCount - On error, the number of missing options.
- /// \return - An InputArgList; on error this will contain all the options
+ /// \return An InputArgList; on error this will contain all the options
/// which could be parsed.
InputArgList *ParseArgs(const char* const *ArgBegin,
const char* const *ArgEnd,
unsigned &MissingArgIndex,
unsigned &MissingArgCount) const;
- /// PrintHelp - Render the help text for an option table.
+ /// \brief Render the help text for an option table.
///
/// \param OS - The stream to write the help text to.
/// \param Name - The name to use in the usage line.
Modified: cfe/branches/tooling/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Driver/Options.td?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Driver/Options.td (original)
+++ cfe/branches/tooling/include/clang/Driver/Options.td Fri Jun 15 06:08:27 2012
@@ -407,6 +407,10 @@
def ffor_scope : Flag<"-ffor-scope">, Group<f_Group>;
def fno_for_scope : Flag<"-fno-for-scope">, Group<f_Group>;
+def frewrite_includes : Flag<"-frewrite-includes">, Group<f_Group>,
+ Flags<[CC1Option]>;
+def fno_rewrite_includes : Flag<"-fno-rewrite-includes">, Group<f_Group>;
+
def ffreestanding : Flag<"-ffreestanding">, Group<f_Group>, Flags<[CC1Option]>,
HelpText<"Assert that the compilation takes place in a freestanding environment">;
def fgnu_keywords : Flag<"-fgnu-keywords">, Group<f_Group>, Flags<[CC1Option]>,
@@ -831,6 +835,7 @@
def no_cpp_precomp : Flag<"-no-cpp-precomp">, Group<clang_ignored_f_Group>;
def no_integrated_as : Flag<"-no-integrated-as">, Flags<[DriverOption]>;
def no_integrated_cpp : Flag<"-no-integrated-cpp">, Flags<[DriverOption]>;
+def no_pedantic : Flag<"-no-pedantic">, Group<pedantic_Group>;
def no__dead__strip__inits__and__terms : Flag<"-no_dead_strip_inits_and_terms">;
def nobuiltininc : Flag<"-nobuiltininc">, Flags<[CC1Option]>,
HelpText<"Disable builtin #include directories">;
@@ -1033,6 +1038,7 @@
def _machine : Separate<"--machine">, Alias<m_Joined>;
def _no_integrated_cpp : Flag<"--no-integrated-cpp">, Alias<no_integrated_cpp>;
def _no_line_commands : Flag<"--no-line-commands">, Alias<P>;
+def _no_pedantic : Flag<"--no-pedantic">, Alias<no_pedantic>;
def _no_standard_includes : Flag<"--no-standard-includes">, Alias<nostdinc>;
def _no_standard_libraries : Flag<"--no-standard-libraries">, Alias<nostdlib>;
def _no_undefined : Flag<"--no-undefined">, Flags<[LinkerInput]>;
Modified: cfe/branches/tooling/include/clang/Driver/Types.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Driver/Types.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Driver/Types.h (original)
+++ cfe/branches/tooling/include/clang/Driver/Types.h Fri Jun 15 06:08:27 2012
@@ -23,7 +23,7 @@
TY_LAST
};
- /// getTypeName - Return the name of the type for \arg Id.
+ /// getTypeName - Return the name of the type for \p Id.
const char *getTypeName(ID Id);
/// getPreprocessedType - Get the ID of the type for this input when
@@ -70,7 +70,7 @@
bool isObjC(ID Id);
/// lookupTypeForExtension - Lookup the type to use for the file
- /// extension \arg Ext.
+ /// extension \p Ext.
ID lookupTypeForExtension(const char *Ext);
/// lookupTypeForTypSpecifier - Lookup the type to use for a user
@@ -81,7 +81,7 @@
/// to be done for this type.
unsigned getNumCompilationPhases(ID Id);
- /// getCompilationPhase - Return the \args N th compilation phase to
+ /// getCompilationPhase - Return the \p N th compilation phase to
/// be done for this type.
phases::ID getCompilationPhase(ID Id, unsigned N);
Modified: cfe/branches/tooling/include/clang/Frontend/CompilerInvocation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Frontend/CompilerInvocation.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Frontend/CompilerInvocation.h (original)
+++ cfe/branches/tooling/include/clang/Frontend/CompilerInvocation.h Fri Jun 15 06:08:27 2012
@@ -127,7 +127,7 @@
/// toArgs - Convert the CompilerInvocation to a list of strings suitable for
/// passing to CreateFromArgs.
- void toArgs(std::vector<std::string> &Res);
+ void toArgs(std::vector<std::string> &Res) const;
/// setLangDefaults - Set language defaults for the given input language and
/// language standard in this CompilerInvocation.
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=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Frontend/FrontendAction.h (original)
+++ cfe/branches/tooling/include/clang/Frontend/FrontendAction.h Fri Jun 15 06:08:27 2012
@@ -188,7 +188,7 @@
bool BeginSourceFile(CompilerInstance &CI, const FrontendInputFile &Input);
/// Execute - Set the source managers main input file, and run the action.
- void Execute();
+ bool Execute();
/// EndSourceFile - Perform any per-file post processing, deallocate per-file
/// objects, and run statistics and output file cleanup code.
Modified: cfe/branches/tooling/include/clang/Frontend/FrontendOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Frontend/FrontendOptions.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Frontend/FrontendOptions.h (original)
+++ cfe/branches/tooling/include/clang/Frontend/FrontendOptions.h Fri Jun 15 06:08:27 2012
@@ -42,7 +42,7 @@
PrintDeclContext, ///< Print DeclContext and their Decls.
PrintPreamble, ///< Print the "preamble" of the input file
PrintPreprocessedInput, ///< -E mode.
- RewriteMacros, ///< Expand macros but not #includes.
+ RewriteMacros, ///< Expand macros but not \#includes.
RewriteObjC, ///< ObjC->C Rewriter.
RewriteTest, ///< Rewriter playground
RunAnalysis, ///< Run one or more source code analyses.
Modified: cfe/branches/tooling/include/clang/Frontend/HeaderSearchOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Frontend/HeaderSearchOptions.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Frontend/HeaderSearchOptions.h (original)
+++ cfe/branches/tooling/include/clang/Frontend/HeaderSearchOptions.h Fri Jun 15 06:08:27 2012
@@ -17,12 +17,12 @@
namespace frontend {
/// IncludeDirGroup - Identifiers the group a include entry belongs to, which
- /// represents its relative positive in the search list. A #include of a ""
+ /// represents its relative positive in the search list. A \#include of a ""
/// path starts at the -iquote group, then searches the Angled group, then
/// searches the system group, etc.
enum IncludeDirGroup {
- Quoted = 0, ///< '#include ""' paths, added by'gcc -iquote'.
- Angled, ///< Paths for '#include <>' added by '-I'.
+ Quoted = 0, ///< '\#include ""' paths, added by 'gcc -iquote'.
+ Angled, ///< Paths for '\#include <>' added by '-I'.
IndexHeaderMap, ///< Like Angled, but marks header maps used when
/// building frameworks.
System, ///< Like Angled, but marks system directories.
@@ -69,6 +69,18 @@
IsInternal(isInternal), ImplicitExternC(implicitExternC) {}
};
+ struct SystemHeaderPrefix {
+ /// A prefix to be matched against paths in #include directives.
+ std::string Prefix;
+
+ /// True if paths beginning with this prefix should be treated as system
+ /// headers.
+ bool IsSystemHeader;
+
+ SystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader)
+ : Prefix(Prefix), IsSystemHeader(IsSystemHeader) {}
+ };
+
/// If non-empty, the directory to use as a "virtual system root" for include
/// paths.
std::string Sysroot;
@@ -76,6 +88,9 @@
/// User specified include entries.
std::vector<Entry> UserEntries;
+ /// User-specified system header prefixes.
+ std::vector<SystemHeaderPrefix> SystemHeaderPrefixes;
+
/// The directory which holds the compiler resource files (builtin includes,
/// etc.).
std::string ResourceDir;
@@ -117,6 +132,13 @@
UserEntries.push_back(Entry(Path, Group, IsUserSupplied, IsFramework,
IgnoreSysRoot, IsInternal, ImplicitExternC));
}
+
+ /// AddSystemHeaderPrefix - Override whether #include directives naming a
+ /// path starting with \arg Prefix should be considered as naming a system
+ /// header.
+ void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
+ SystemHeaderPrefixes.push_back(SystemHeaderPrefix(Prefix, IsSystemHeader));
+ }
};
} // end namespace clang
Modified: cfe/branches/tooling/include/clang/Frontend/PreprocessorOutputOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Frontend/PreprocessorOutputOptions.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Frontend/PreprocessorOutputOptions.h (original)
+++ cfe/branches/tooling/include/clang/Frontend/PreprocessorOutputOptions.h Fri Jun 15 06:08:27 2012
@@ -18,9 +18,10 @@
public:
unsigned ShowCPP : 1; ///< Print normal preprocessed output.
unsigned ShowComments : 1; ///< Show comments.
- unsigned ShowLineMarkers : 1; ///< Show #line markers.
+ unsigned ShowLineMarkers : 1; ///< Show \#line markers.
unsigned ShowMacroComments : 1; ///< Show comments, even in macros.
unsigned ShowMacros : 1; ///< Print macro definitions.
+ unsigned RewriteIncludes : 1; ///< Preprocess include directives only.
public:
PreprocessorOutputOptions() {
@@ -29,6 +30,7 @@
ShowLineMarkers = 1;
ShowMacroComments = 0;
ShowMacros = 0;
+ RewriteIncludes = 0;
}
};
Modified: cfe/branches/tooling/include/clang/Lex/CodeCompletionHandler.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Lex/CodeCompletionHandler.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Lex/CodeCompletionHandler.h (original)
+++ cfe/branches/tooling/include/clang/Lex/CodeCompletionHandler.h Fri Jun 15 06:08:27 2012
@@ -47,7 +47,7 @@
virtual void CodeCompleteMacroName(bool IsDefinition) { }
/// \brief Callback invoked when performing code completion in a preprocessor
- /// expression, such as the condition of an #if or #elif directive.
+ /// expression, such as the condition of an \#if or \#elif directive.
virtual void CodeCompletePreprocessorExpression() { }
/// \brief Callback invoked when performing code completion inside a
@@ -62,7 +62,7 @@
/// \brief Callback invoked when performing code completion in a part of the
/// file where we expect natural language, e.g., a comment, string, or
- /// #error directive.
+ /// \#error directive.
virtual void CodeCompleteNaturalLanguage() { }
};
Modified: cfe/branches/tooling/include/clang/Lex/HeaderSearch.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Lex/HeaderSearch.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/branches/tooling/include/clang/Lex/HeaderSearch.h Fri Jun 15 06:08:27 2012
@@ -16,6 +16,7 @@
#include "clang/Lex/DirectoryLookup.h"
#include "clang/Lex/ModuleMap.h"
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/Allocator.h"
@@ -31,12 +32,12 @@
class IdentifierInfo;
/// HeaderFileInfo - The preprocessor keeps track of this information for each
-/// file that is #included.
+/// file that is \#included.
struct HeaderFileInfo {
- /// isImport - True if this is a #import'd or #pragma once file.
+ /// isImport - True if this is a \#import'd or \#pragma once file.
unsigned isImport : 1;
- /// isPragmaOnce - True if this is #pragma once file.
+ /// isPragmaOnce - True if this is \#pragma once file.
unsigned isPragmaOnce : 1;
/// DirInfo - Keep track of whether this is a system header, and if so,
@@ -144,6 +145,12 @@
unsigned SystemDirIdx;
bool NoCurDirSearch;
+ /// #include prefixes for which the 'system header' property is overridden.
+ /// For a #include "x" or #include <x> directive, the last string in this
+ /// list which is a prefix of 'x' determines whether the file is treated as
+ /// a system header.
+ std::vector<std::pair<std::string, bool> > SystemHeaderPrefixes;
+
/// \brief The path to the module cache.
std::string ModuleCachePath;
@@ -235,6 +242,11 @@
SystemDirIdx++;
}
+ /// SetSystemHeaderPrefixes - Set the list of system header prefixes.
+ void SetSystemHeaderPrefixes(ArrayRef<std::pair<std::string, bool> > P) {
+ SystemHeaderPrefixes.assign(P.begin(), P.end());
+ }
+
/// HasIncludeAliasMap - Checks whether the map exists or not
bool HasIncludeAliasMap() const {
return IncludeAliases;
@@ -379,17 +391,17 @@
/// SetFileControllingMacro - Mark the specified file as having a controlling
/// macro. This is used by the multiple-include optimization to eliminate
- /// no-op #includes.
+ /// no-op \#includes.
void SetFileControllingMacro(const FileEntry *File,
const IdentifierInfo *ControllingMacro) {
getFileInfo(File).ControllingMacro = ControllingMacro;
}
/// \brief Determine whether this file is intended to be safe from
- /// multiple inclusions, e.g., it has #pragma once or a controlling
+ /// multiple inclusions, e.g., it has \#pragma once or a controlling
/// macro.
///
- /// This routine does not consider the effect of #import
+ /// This routine does not consider the effect of \#import
bool isFileMultipleIncludeGuarded(const FileEntry *File);
/// CreateHeaderMap - This method returns a HeaderMap for the specified
Modified: cfe/branches/tooling/include/clang/Lex/Lexer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Lex/Lexer.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Lex/Lexer.h (original)
+++ cfe/branches/tooling/include/clang/Lex/Lexer.h Fri Jun 15 06:08:27 2012
@@ -97,14 +97,14 @@
Lexer(FileID FID, const llvm::MemoryBuffer *InputBuffer, Preprocessor &PP);
/// Lexer constructor - Create a new raw lexer object. This object is only
- /// suitable for calls to 'LexRawToken'. This lexer assumes that the text
- /// range will outlive it, so it doesn't take ownership of it.
+ /// suitable for calls to 'LexFromRawLexer'. This lexer assumes that the
+ /// text range will outlive it, so it doesn't take ownership of it.
Lexer(SourceLocation FileLoc, const LangOptions &LangOpts,
const char *BufStart, const char *BufPtr, const char *BufEnd);
/// Lexer constructor - Create a new raw lexer object. This object is only
- /// suitable for calls to 'LexRawToken'. This lexer assumes that the text
- /// range will outlive it, so it doesn't take ownership of it.
+ /// suitable for calls to 'LexFromRawLexer'. This lexer assumes that the
+ /// text range will outlive it, so it doesn't take ownership of it.
Lexer(FileID FID, const llvm::MemoryBuffer *InputBuffer,
const SourceManager &SM, const LangOptions &LangOpts);
@@ -541,6 +541,9 @@
const LangOptions &LangOpts,
bool SkipTrailingWhitespaceAndNewLine);
+ /// \brief Returns true if the given character could appear in an identifier.
+ static bool isIdentifierBodyChar(char c, const LangOptions &LangOpts);
+
private:
/// getCharAndSizeSlowNoWarn - Same as getCharAndSizeSlow, but never emits a
Modified: cfe/branches/tooling/include/clang/Lex/ModuleMap.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Lex/ModuleMap.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Lex/ModuleMap.h (original)
+++ cfe/branches/tooling/include/clang/Lex/ModuleMap.h Fri Jun 15 06:08:27 2012
@@ -126,7 +126,7 @@
/// \brief Retrieve a module with the given name.
///
- /// \param The name of the module to look up.
+ /// \param Name The name of the module to look up.
///
/// \returns The named module, if known; otherwise, returns null.
Module *findModule(StringRef Name);
@@ -134,7 +134,7 @@
/// \brief Retrieve a module with the given name using lexical name lookup,
/// starting at the given context.
///
- /// \param The name of the module to look up.
+ /// \param Name The name of the module to look up.
///
/// \param Context The module context, from which we will perform lexical
/// name lookup.
Modified: cfe/branches/tooling/include/clang/Lex/PPCallbacks.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Lex/PPCallbacks.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Lex/PPCallbacks.h (original)
+++ cfe/branches/tooling/include/clang/Lex/PPCallbacks.h Fri Jun 15 06:08:27 2012
@@ -76,7 +76,7 @@
}
/// \brief This callback is invoked whenever an inclusion directive of
- /// any kind (\c #include, \c #import, etc.) has been processed, regardless
+ /// any kind (\c \#include, \c \#import, etc.) has been processed, regardless
/// of whether the inclusion will actually result in an inclusion.
///
/// \param HashLoc The location of the '#' that starts the inclusion
@@ -342,38 +342,38 @@
Second->SourceRangeSkipped(Range);
}
- /// If -- This hook is called whenever an #if is seen.
+ /// If -- This hook is called whenever an \#if is seen.
virtual void If(SourceLocation Loc, SourceRange ConditionRange) {
First->If(Loc, ConditionRange);
Second->If(Loc, ConditionRange);
}
- /// Elif -- This hook is called whenever an #if is seen.
+ /// Elif -- This hook is called whenever an \#if is seen.
virtual void Elif(SourceLocation Loc, SourceRange ConditionRange,
SourceLocation IfLoc) {
First->Elif(Loc, ConditionRange, IfLoc);
Second->Elif(Loc, ConditionRange, IfLoc);
}
- /// Ifdef -- This hook is called whenever an #ifdef is seen.
+ /// Ifdef -- This hook is called whenever an \#ifdef is seen.
virtual void Ifdef(SourceLocation Loc, const Token &MacroNameTok) {
First->Ifdef(Loc, MacroNameTok);
Second->Ifdef(Loc, MacroNameTok);
}
- /// Ifndef -- This hook is called whenever an #ifndef is seen.
+ /// Ifndef -- This hook is called whenever an \#ifndef is seen.
virtual void Ifndef(SourceLocation Loc, const Token &MacroNameTok) {
First->Ifndef(Loc, MacroNameTok);
Second->Ifndef(Loc, MacroNameTok);
}
- /// Else -- This hook is called whenever an #else is seen.
+ /// Else -- This hook is called whenever an \#else is seen.
virtual void Else(SourceLocation Loc, SourceLocation IfLoc) {
First->Else(Loc, IfLoc);
Second->Else(Loc, IfLoc);
}
- /// Endif -- This hook is called whenever an #endif is seen.
+ /// Endif -- This hook is called whenever an \#endif is seen.
virtual void Endif(SourceLocation Loc, SourceLocation IfLoc) {
First->Endif(Loc, IfLoc);
Second->Endif(Loc, IfLoc);
Modified: cfe/branches/tooling/include/clang/Lex/Pragma.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Lex/Pragma.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Lex/Pragma.h (original)
+++ cfe/branches/tooling/include/clang/Lex/Pragma.h Fri Jun 15 06:08:27 2012
@@ -26,12 +26,12 @@
class PragmaNamespace;
/**
- * \brief Describes how the pragma was introduced, e.g., with #pragma,
+ * \brief Describes how the pragma was introduced, e.g., with \#pragma,
* _Pragma, or __pragma.
*/
enum PragmaIntroducerKind {
/**
- * \brief The pragma was introduced via #pragma.
+ * \brief The pragma was introduced via \#pragma.
*/
PIK_HashPragma,
@@ -54,7 +54,7 @@
/// pragmas the handler with a null identifier is invoked, if it exists.
///
/// Note that the PragmaNamespace class can be used to subdivide pragmas, e.g.
-/// we treat "#pragma STDC" and "#pragma GCC" as namespaces that contain other
+/// we treat "\#pragma STDC" and "\#pragma GCC" as namespaces that contain other
/// pragmas.
class PragmaHandler {
std::string Name;
@@ -84,8 +84,8 @@
/// PragmaNamespace - This PragmaHandler subdivides the namespace of pragmas,
/// allowing hierarchical pragmas to be defined. Common examples of namespaces
-/// are "#pragma GCC", "#pragma STDC", and "#pragma omp", but any namespaces may
-/// be (potentially recursively) defined.
+/// are "\#pragma GCC", "\#pragma STDC", and "\#pragma omp", but any namespaces
+/// may be (potentially recursively) defined.
class PragmaNamespace : public PragmaHandler {
/// Handlers - This is a map of the handlers in this namespace with their name
/// as key.
Modified: cfe/branches/tooling/include/clang/Lex/PreprocessingRecord.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Lex/PreprocessingRecord.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Lex/PreprocessingRecord.h (original)
+++ cfe/branches/tooling/include/clang/Lex/PreprocessingRecord.h Fri Jun 15 06:08:27 2012
@@ -59,8 +59,8 @@
/// \brief A macro definition.
MacroDefinitionKind,
- /// \brief An inclusion directive, such as \c #include, \c
- /// #import, or \c #include_next.
+ /// \brief An inclusion directive, such as \c \#include, \c
+ /// \#import, or \c \#include_next.
InclusionDirectiveKind,
/// @}
@@ -197,19 +197,19 @@
};
/// \brief Record the location of an inclusion directive, such as an
- /// \c #include or \c #import statement.
+ /// \c \#include or \c \#import statement.
class InclusionDirective : public PreprocessingDirective {
public:
/// \brief The kind of inclusion directives known to the
/// preprocessor.
enum InclusionKind {
- /// \brief An \c #include directive.
+ /// \brief An \c \#include directive.
Include,
- /// \brief An Objective-C \c #import directive.
+ /// \brief An Objective-C \c \#import directive.
Import,
- /// \brief A GNU \c #include_next directive.
+ /// \brief A GNU \c \#include_next directive.
IncludeNext,
- /// \brief A Clang \c #__include_macros directive.
+ /// \brief A Clang \c \#__include_macros directive.
IncludeMacros
};
@@ -551,7 +551,7 @@
///
/// Can be used to avoid implicit deserializations of preallocated
/// preprocessed entities if we only care about entities of a specific file
- /// and not from files #included in the range given at
+ /// and not from files \#included in the range given at
/// \see getPreprocessedEntitiesInRange.
bool isEntityInFileID(iterator PPEI, FileID FID);
@@ -565,7 +565,7 @@
}
/// \brief Returns true if the given range intersects with a conditional
- /// directive. if a #if/#endif block is fully contained within the range,
+ /// directive. if a \#if/\#endif block is fully contained within the range,
/// this function will return false.
bool rangeIntersectsConditionalDirective(SourceRange Range) const;
Modified: cfe/branches/tooling/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Lex/Preprocessor.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Lex/Preprocessor.h (original)
+++ cfe/branches/tooling/include/clang/Lex/Preprocessor.h Fri Jun 15 06:08:27 2012
@@ -121,9 +121,19 @@
/// DisableMacroExpansion - True if macro expansion is disabled.
bool DisableMacroExpansion : 1;
+ /// MacroExpansionInDirectivesOverride - Temporarily disables
+ /// DisableMacroExpansion (i.e. enables expansion) when parsing preprocessor
+ /// directives.
+ bool MacroExpansionInDirectivesOverride : 1;
+
+ class ResetMacroExpansionHelper;
+
/// \brief Whether we have already loaded macros from the external source.
mutable bool ReadMacrosFromExternalSource : 1;
+ /// \brief True if pragmas are enabled.
+ bool PragmasEnabled : 1;
+
/// \brief True if we are pre-expanding macro arguments.
bool InMacroArgPreExpansion;
@@ -409,6 +419,9 @@
bool getCommentRetentionState() const { return KeepComments; }
+ void setPragmasEnabled(bool Enabled) { PragmasEnabled = Enabled; }
+ bool getPragmasEnabled() const { return PragmasEnabled; }
+
void SetSuppressIncludeNotFoundError(bool Suppress) {
SuppressIncludeNotFoundError = Suppress;
}
@@ -643,6 +656,12 @@
while (Result.getKind() == tok::comment);
}
+ /// Disables macro expansion everywhere except for preprocessor directives.
+ void SetMacroExpansionOnlyInDirectives() {
+ DisableMacroExpansion = true;
+ MacroExpansionInDirectivesOverride = true;
+ }
+
/// LookAhead - This peeks ahead N tokens and returns that token without
/// consuming any tokens. LookAhead(0) returns the next token that would be
/// returned by Lex(), LookAhead(1) returns the token after it, etc. This
@@ -761,25 +780,24 @@
getDiagnostics().setSuppressAllDiagnostics(true);
}
- /// \brief The location of the currently-active #pragma clang
+ /// \brief The location of the currently-active \#pragma clang
/// arc_cf_code_audited begin. Returns an invalid location if there
/// is no such pragma active.
SourceLocation getPragmaARCCFCodeAuditedLoc() const {
return PragmaARCCFCodeAuditedLoc;
}
- /// \brief Set the location of the currently-active #pragma clang
+ /// \brief Set the location of the currently-active \#pragma clang
/// arc_cf_code_audited begin. An invalid location ends the pragma.
void setPragmaARCCFCodeAuditedLoc(SourceLocation Loc) {
PragmaARCCFCodeAuditedLoc = Loc;
}
- /// \brief Instruct the preprocessor to skip part of the main
- /// the main source file.
+ /// \brief Instruct the preprocessor to skip part of the main source file.
///
- /// \brief Bytes The number of bytes in the preamble to skip.
+ /// \param Bytes The number of bytes in the preamble to skip.
///
- /// \brief StartOfLine Whether skipping these bytes puts the lexer at the
+ /// \param StartOfLine Whether skipping these bytes puts the lexer at the
/// start of a line.
void setSkipMainFilePreamble(unsigned Bytes, bool StartOfLine) {
SkipMainFilePreamble.first = Bytes;
Modified: cfe/branches/tooling/include/clang/Lex/PreprocessorLexer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Lex/PreprocessorLexer.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Lex/PreprocessorLexer.h (original)
+++ cfe/branches/tooling/include/clang/Lex/PreprocessorLexer.h Fri Jun 15 06:08:27 2012
@@ -163,7 +163,7 @@
const FileEntry *getFileEntry() const;
/// \brief Iterator that traverses the current stack of preprocessor
- /// conditional directives (#if/#ifdef/#ifndef).
+ /// conditional directives (\#if/\#ifdef/\#ifndef).
typedef SmallVectorImpl<PPConditionalInfo>::const_iterator
conditional_iterator;
Modified: cfe/branches/tooling/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Parse/Parser.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Parse/Parser.h (original)
+++ cfe/branches/tooling/include/clang/Parse/Parser.h Fri Jun 15 06:08:27 2012
@@ -28,6 +28,7 @@
namespace clang {
class PragmaHandler;
class Scope;
+ class BalancedDelimiterTracker;
class DeclGroupRef;
class DiagnosticBuilder;
class Parser;
@@ -83,6 +84,7 @@
friend class InMessageExpressionRAIIObject;
friend class PoisonSEHIdentifiersRAIIObject;
friend class ParenBraceBracketBalancer;
+ friend class BalancedDelimiterTracker;
Preprocessor &PP;
@@ -97,7 +99,7 @@
SourceLocation PrevTokLocation;
unsigned short ParenCount, BracketCount, BraceCount;
-
+
/// Actions - These are the callbacks we invoke as we parse various constructs
/// in the file.
Sema &Actions;
@@ -438,78 +440,6 @@
return PP.LookAhead(0);
}
- /// \brief RAII class that helps handle the parsing of an open/close delimiter
- /// pair, such as braces { ... } or parentheses ( ... ).
- class BalancedDelimiterTracker {
- Parser& P;
- tok::TokenKind Kind, Close;
- SourceLocation (Parser::*Consumer)();
- SourceLocation LOpen, LClose;
-
- unsigned short &getDepth() {
- switch (Kind) {
- case tok::l_brace: return P.BraceCount;
- case tok::l_square: return P.BracketCount;
- case tok::l_paren: return P.ParenCount;
- default: llvm_unreachable("Wrong token kind");
- }
- }
-
- enum { MaxDepth = 256 };
-
- bool diagnoseOverflow();
- bool diagnoseMissingClose();
-
- public:
- BalancedDelimiterTracker(Parser& p, tok::TokenKind k) : P(p), Kind(k) {
- switch (Kind) {
- default: llvm_unreachable("Unexpected balanced token");
- case tok::l_brace:
- Close = tok::r_brace;
- Consumer = &Parser::ConsumeBrace;
- break;
- case tok::l_paren:
- Close = tok::r_paren;
- Consumer = &Parser::ConsumeParen;
- break;
-
- case tok::l_square:
- Close = tok::r_square;
- Consumer = &Parser::ConsumeBracket;
- break;
- }
- }
-
- SourceLocation getOpenLocation() const { return LOpen; }
- SourceLocation getCloseLocation() const { return LClose; }
- SourceRange getRange() const { return SourceRange(LOpen, LClose); }
-
- bool consumeOpen() {
- if (!P.Tok.is(Kind))
- return true;
-
- if (getDepth() < MaxDepth) {
- LOpen = (P.*Consumer)();
- return false;
- }
-
- return diagnoseOverflow();
- }
-
- bool expectAndConsume(unsigned DiagID,
- const char *Msg = "",
- tok::TokenKind SkipToTok = tok::unknown);
- bool consumeClose() {
- if (P.Tok.is(Close)) {
- LClose = (P.*Consumer)();
- return false;
- }
-
- return diagnoseMissingClose();
- }
- void skipToEnd();
- };
-
/// getTypeAnnotation - Read a parsed type out of an annotation token.
static ParsedType getTypeAnnotation(Token &Tok) {
return ParsedType::getFromOpaquePtr(Tok.getAnnotationValue());
@@ -730,6 +660,9 @@
public:
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID);
DiagnosticBuilder Diag(const Token &Tok, unsigned DiagID);
+ DiagnosticBuilder Diag(unsigned DiagID) {
+ return Diag(Tok, DiagID);
+ }
private:
void SuggestParentheses(SourceLocation Loc, unsigned DK,
Modified: cfe/branches/tooling/include/clang/Rewrite/FrontendActions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Rewrite/FrontendActions.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Rewrite/FrontendActions.h (original)
+++ cfe/branches/tooling/include/clang/Rewrite/FrontendActions.h Fri Jun 15 06:08:27 2012
@@ -73,6 +73,11 @@
void ExecuteAction();
};
+class RewriteIncludesAction : public PreprocessorFrontendAction {
+protected:
+ void ExecuteAction();
+};
+
} // end namespace clang
#endif
Modified: cfe/branches/tooling/include/clang/Rewrite/Rewriters.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Rewrite/Rewriters.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Rewrite/Rewriters.h (original)
+++ cfe/branches/tooling/include/clang/Rewrite/Rewriters.h Fri Jun 15 06:08:27 2012
@@ -18,6 +18,7 @@
namespace clang {
class Preprocessor;
+class PreprocessorOutputOptions;
/// RewriteMacrosInInput - Implement -rewrite-macros mode.
void RewriteMacrosInInput(Preprocessor &PP, raw_ostream *OS);
@@ -25,6 +26,10 @@
/// DoRewriteTest - A simple test for the TokenRewriter class.
void DoRewriteTest(Preprocessor &PP, raw_ostream *OS);
+/// RewriteIncludesInInput - Implement -frewrite-includes mode.
+void RewriteIncludesInInput(Preprocessor &PP, raw_ostream *OS,
+ const PreprocessorOutputOptions &Opts);
+
} // end namespace clang
#endif
Modified: cfe/branches/tooling/include/clang/Sema/CodeCompleteConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/CodeCompleteConsumer.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/CodeCompleteConsumer.h (original)
+++ cfe/branches/tooling/include/clang/Sema/CodeCompleteConsumer.h Fri Jun 15 06:08:27 2012
@@ -237,7 +237,7 @@
/// This context usually implies that no completions should be added,
/// unless they come from an appropriate natural-language dictionary.
CCC_NaturalLanguage,
- /// \brief Code completion for a selector, as in an @selector expression.
+ /// \brief Code completion for a selector, as in an \@selector expression.
CCC_SelectorName,
/// \brief Code completion within a type-qualifier list.
CCC_TypeQualifiers,
@@ -379,7 +379,7 @@
CK_Equal,
/// \brief Horizontal whitespace (' ').
CK_HorizontalSpace,
- /// \brief Verticle whitespace ('\n' or '\r\n', depending on the
+ /// \brief Vertical whitespace ('\\n' or '\\r\\n', depending on the
/// platform).
CK_VerticalSpace
};
@@ -638,10 +638,10 @@
public:
/// \brief Describes the kind of result generated.
enum ResultKind {
- RK_Declaration = 0, //< Refers to a declaration
- RK_Keyword, //< Refers to a keyword or symbol.
- RK_Macro, //< Refers to a macro
- RK_Pattern //< Refers to a precomputed pattern.
+ RK_Declaration = 0, ///< Refers to a declaration
+ RK_Keyword, ///< Refers to a keyword or symbol.
+ RK_Macro, ///< Refers to a macro
+ RK_Pattern ///< Refers to a precomputed pattern.
};
/// \brief When Kind == RK_Declaration or RK_Pattern, the declaration we are
Modified: cfe/branches/tooling/include/clang/Sema/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/DeclSpec.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/DeclSpec.h (original)
+++ cfe/branches/tooling/include/clang/Sema/DeclSpec.h Fri Jun 15 06:08:27 2012
@@ -1104,6 +1104,10 @@
/// DeleteArgInfo - If this is true, we need to delete[] ArgInfo.
unsigned DeleteArgInfo : 1;
+ /// HasTrailingReturnType - If this is true, a trailing return type was
+ /// specified.
+ unsigned HasTrailingReturnType : 1;
+
/// When isVariadic is true, the location of the ellipsis in the source.
unsigned EllipsisLoc;
@@ -1154,10 +1158,9 @@
Expr *NoexceptExpr;
};
- /// TrailingReturnType - If this isn't null, it's the trailing return type
- /// specified. This is actually a ParsedType, but stored as void* to
- /// allow union storage.
- void *TrailingReturnType;
+ /// TrailingReturnType - If HasTrailingReturnType is true, this is the
+ /// trailing return type specified.
+ UnionParsedType TrailingReturnType;
/// freeArgs - reset the argument list to having zero arguments. This is
/// used in various places for error recovery.
@@ -1222,6 +1225,13 @@
ExceptionSpecificationType getExceptionSpecType() const {
return static_cast<ExceptionSpecificationType>(ExceptionSpecType);
}
+
+ /// \brief Determine whether this function declarator had a
+ /// trailing-return-type.
+ bool hasTrailingReturnType() const { return HasTrailingReturnType; }
+
+ /// \brief Get the trailing-return-type for this function declarator.
+ ParsedType getTrailingReturnType() const { return TrailingReturnType; }
};
struct BlockPointerTypeInfo : TypeInfoCommon {
@@ -1352,8 +1362,8 @@
SourceLocation LocalRangeBegin,
SourceLocation LocalRangeEnd,
Declarator &TheDeclarator,
- ParsedType TrailingReturnType =
- ParsedType());
+ TypeResult TrailingReturnType =
+ TypeResult());
/// getBlockPointer - Return a DeclaratorChunk for a block.
///
Modified: cfe/branches/tooling/include/clang/Sema/Designator.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/Designator.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/Designator.h (original)
+++ cfe/branches/tooling/include/clang/Sema/Designator.h Fri Jun 15 06:08:27 2012
@@ -179,18 +179,10 @@
/// Designation - Represent a full designation, which is a sequence of
/// designators. This class is mostly a helper for InitListDesignations.
class Designation {
- /// InitIndex - The index of the initializer expression this is for. For
- /// example, if the initializer were "{ A, .foo=B, C }" a Designation would
- /// exist with InitIndex=1, because element #1 has a designation.
- unsigned InitIndex;
-
/// Designators - The actual designators for this initializer.
SmallVector<Designator, 2> Designators;
- Designation(unsigned Idx) : InitIndex(Idx) {}
public:
- Designation() : InitIndex(4000) {}
-
/// AddDesignator - Add a designator to the end of this list.
void AddDesignator(Designator D) {
Designators.push_back(D);
Modified: cfe/branches/tooling/include/clang/Sema/ParsedTemplate.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/ParsedTemplate.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/ParsedTemplate.h (original)
+++ cfe/branches/tooling/include/clang/Sema/ParsedTemplate.h Fri Jun 15 06:08:27 2012
@@ -58,7 +58,7 @@
SourceLocation TemplateLoc)
: Kind(ParsedTemplateArgument::Template),
Arg(Template.getAsOpaquePtr()),
- Loc(TemplateLoc), SS(SS), EllipsisLoc() { }
+ SS(SS), Loc(TemplateLoc), EllipsisLoc() { }
/// \brief Determine whether the given template argument is invalid.
bool isInvalid() const { return Arg == 0; }
@@ -118,13 +118,13 @@
/// expression), or an ActionBase::TemplateTy (for a template).
void *Arg;
- /// \brief the location of the template argument.
- SourceLocation Loc;
-
/// \brief The nested-name-specifier that can accompany a template template
/// argument.
CXXScopeSpec SS;
-
+
+ /// \brief the location of the template argument.
+ SourceLocation Loc;
+
/// \brief The ellipsis location that can accompany a template template
/// argument (turning it into a template template argument expansion).
SourceLocation EllipsisLoc;
Modified: cfe/branches/tooling/include/clang/Sema/Scope.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/Scope.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/Scope.h (original)
+++ cfe/branches/tooling/include/clang/Sema/Scope.h Fri Jun 15 06:08:27 2012
@@ -71,7 +71,7 @@
FunctionPrototypeScope = 0x100,
/// AtCatchScope - This is a scope that corresponds to the Objective-C
- /// @catch statement.
+ /// \@catch statement.
AtCatchScope = 0x200,
/// ObjCMethodScope - This scope corresponds to an Objective-C method body.
@@ -270,7 +270,7 @@
return getFlags() & Scope::FunctionPrototypeScope;
}
- /// isAtCatchScope - Return true if this scope is @catch.
+ /// isAtCatchScope - Return true if this scope is \@catch.
bool isAtCatchScope() const {
return getFlags() & Scope::AtCatchScope;
}
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=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/branches/tooling/include/clang/Sema/ScopeInfo.h Fri Jun 15 06:08:27 2012
@@ -74,7 +74,7 @@
///
ScopeKind Kind;
- /// \brief Whether this function contains a VLA, @try, try, C++
+ /// \brief Whether this function contains a VLA, \@try, try, C++
/// initializer, or anything else that can't be jumped past.
bool HasBranchProtectedScope;
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=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/Sema.h (original)
+++ cfe/branches/tooling/include/clang/Sema/Sema.h Fri Jun 15 06:08:27 2012
@@ -222,13 +222,13 @@
/// This is used as part of a hack to omit that class from ADL results.
DeclarationName VAListTagName;
- /// PackContext - Manages the stack for #pragma pack. An alignment
+ /// PackContext - Manages the stack for \#pragma pack. An alignment
/// of 0 indicates default alignment.
void *PackContext; // Really a "PragmaPackStack*"
- bool MSStructPragmaOn; // True when #pragma ms_struct on
+ bool MSStructPragmaOn; // True when \#pragma ms_struct on
- /// VisContext - Manages the stack for #pragma GCC visibility.
+ /// VisContext - Manages the stack for \#pragma GCC visibility.
void *VisContext; // Really a "PragmaVisStack*"
/// ExprNeedsCleanups - True if the current evaluation context
@@ -454,12 +454,12 @@
};
/// WeakUndeclaredIdentifiers - Identifiers contained in
- /// #pragma weak before declared. rare. may alias another
+ /// \#pragma weak before declared. rare. may alias another
/// identifier, declared or undeclared
llvm::DenseMap<IdentifierInfo*,WeakInfo> WeakUndeclaredIdentifiers;
/// ExtnameUndeclaredIdentifiers - Identifiers contained in
- /// #pragma redefine_extname before declared. Used in Solaris system headers
+ /// \#pragma redefine_extname before declared. Used in Solaris system headers
/// to define functions that occur in multiple standards to call the version
/// in the currently selected standard.
llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*> ExtnameUndeclaredIdentifiers;
@@ -469,7 +469,7 @@
void LoadExternalWeakUndeclaredIdentifiers();
/// WeakTopLevelDecl - Translation-unit scoped declarations generated by
- /// #pragma weak during processing of other Decls.
+ /// \#pragma weak during processing of other Decls.
/// I couldn't figure out a clean way to generate these in-line, so
/// we store them here and handle separately -- which is a hack.
/// It would be best to refactor this.
@@ -490,10 +490,10 @@
LazyDeclPtr StdBadAlloc;
/// \brief The C++ "std::initializer_list" template, which is defined in
- /// <initializer_list>.
+ /// \<initializer_list>.
ClassTemplateDecl *StdInitializerList;
- /// \brief The C++ "type_info" declaration, which is defined in <typeinfo>.
+ /// \brief The C++ "type_info" declaration, which is defined in \<typeinfo>.
RecordDecl *CXXTypeInfoDecl;
/// \brief The MSVC "_GUID" struct, which is defined in MSVC header files.
@@ -719,7 +719,7 @@
/// of selectors are "overloaded").
GlobalMethodPool MethodPool;
- /// Method selectors used in a @selector expression. Used for implementation
+ /// Method selectors used in a \@selector expression. Used for implementation
/// of -Wselector.
llvm::DenseMap<Selector, SourceLocation> ReferencedSelectors;
@@ -846,7 +846,7 @@
/// \brief Retrieve the current lambda expression, if any.
sema::LambdaScopeInfo *getCurLambda();
- /// WeakTopLevelDeclDecls - access to #pragma weak-generated Decls
+ /// WeakTopLevelDeclDecls - access to \#pragma weak-generated Decls
SmallVector<Decl*,2> &WeakTopLevelDecls() { return WeakTopLevelDecl; }
//===--------------------------------------------------------------------===//
@@ -1420,13 +1420,15 @@
Declarator &D, Expr *BitfieldWidth);
FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart,
- Declarator &D, Expr *BitfieldWidth, bool HasInit,
+ Declarator &D, Expr *BitfieldWidth,
+ InClassInitStyle InitStyle,
AccessSpecifier AS);
FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T,
TypeSourceInfo *TInfo,
RecordDecl *Record, SourceLocation Loc,
- bool Mutable, Expr *BitfieldWidth, bool HasInit,
+ bool Mutable, Expr *BitfieldWidth,
+ InClassInitStyle InitStyle,
SourceLocation TSSL,
AccessSpecifier AS, NamedDecl *PrevDecl,
Declarator *D = 0);
@@ -2217,7 +2219,7 @@
SourceLocation Loc);
/// ImplMethodsVsClassMethods - This is main routine to warn if any method
- /// remains unimplemented in the class or category @implementation.
+ /// remains unimplemented in the class or category \@implementation.
void ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl,
ObjCContainerDecl* IDecl,
bool IncompleteImpl = false);
@@ -2229,7 +2231,7 @@
const SelectorSet &InsMap);
/// DefaultSynthesizeProperties - This routine default synthesizes all
- /// properties which must be synthesized in class's @implementation.
+ /// properties which must be synthesized in the class's \@implementation.
void DefaultSynthesizeProperties (Scope *S, ObjCImplDecl* IMPDecl,
ObjCInterfaceDecl *IDecl);
void DefaultSynthesizeProperties(Scope *S, Decl *D);
@@ -2246,8 +2248,8 @@
ObjCPropertyDecl *LookupPropertyDecl(const ObjCContainerDecl *CDecl,
IdentifierInfo *II);
- /// Called by ActOnProperty to handle @property declarations in
- //// class extensions.
+ /// Called by ActOnProperty to handle \@property declarations in
+ /// class extensions.
Decl *HandlePropertyInClassExtension(Scope *S,
SourceLocation AtLoc,
SourceLocation LParenLoc,
@@ -2263,7 +2265,7 @@
tok::ObjCKeywordKind MethodImplKind);
/// Called by ActOnProperty and HandlePropertyInClassExtension to
- /// handle creating the ObjcPropertyDecl for a category or @interface.
+ /// handle creating the ObjcPropertyDecl for a category or \@interface.
ObjCPropertyDecl *CreatePropertyDecl(Scope *S,
ObjCContainerDecl *CDecl,
SourceLocation AtLoc,
@@ -2528,6 +2530,9 @@
SourceLocation RParenLoc,
bool MSAsm = false);
+ StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc,
+ std::string &AsmString,
+ SourceLocation EndLoc);
VarDecl *BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType,
SourceLocation StartLoc,
@@ -2736,10 +2741,10 @@
/// \brief Conditionally issue a diagnostic based on the current
/// evaluation context.
///
- /// \param stmt - If stmt is non-null, delay reporting the diagnostic until
- /// the function body is parsed, and then do a basic reachability analysis to
- /// determine if the statement is reachable. If it is unreachable, the
- /// diagnostic will not be emitted.
+ /// \param Statement If Statement is non-null, delay reporting the
+ /// diagnostic until the function body is parsed, and then do a basic
+ /// reachability analysis to determine if the statement is reachable.
+ /// If it is unreachable, the diagnostic will not be emitted.
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement,
const PartialDiagnostic &PD);
@@ -3574,8 +3579,6 @@
/// \brief Try to retrieve the type of the 'this' pointer.
///
- /// \param Capture If true, capture 'this' in this context.
- ///
/// \returns The type of 'this', if possible. Otherwise, returns a NULL type.
QualType getCurrentThisType();
@@ -3907,7 +3910,7 @@
/// including this new type).
///
/// \param TemplateKWLoc the location of the 'template' keyword, if any.
- /// \param TemplateName The template name.
+ /// \param TemplateName the template name.
/// \param TemplateNameLoc The location of the template name.
/// \param LAngleLoc The location of the opening angle bracket ('<').
/// \param TemplateArgs The template arguments.
@@ -3922,7 +3925,7 @@
bool ActOnCXXNestedNameSpecifier(Scope *S,
CXXScopeSpec &SS,
SourceLocation TemplateKWLoc,
- TemplateTy Template,
+ TemplateTy TemplateName,
SourceLocation TemplateNameLoc,
SourceLocation LAngleLoc,
ASTTemplateArgsPtr TemplateArgs,
@@ -4069,11 +4072,11 @@
bool Value);
ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements);
- // BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the
- // '@' prefixed parenthesized expression. The type of the expression will
- // either be "NSNumber *" or "NSString *" depending on the type of
- // ValueType, which is allowed to be a built-in numeric type or
- // "char *" or "const char *".
+ /// BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the
+ /// '@' prefixed parenthesized expression. The type of the expression will
+ /// either be "NSNumber *" or "NSString *" depending on the type of
+ /// ValueType, which is allowed to be a built-in numeric type or
+ /// "char *" or "const char *".
ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr);
ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr,
@@ -4081,7 +4084,7 @@
ObjCMethodDecl *getterMethod,
ObjCMethodDecl *setterMethod);
- ExprResult BuildObjCDictionaryLiteral(SourceRange SR,
+ ExprResult BuildObjCDictionaryLiteral(SourceRange SR,
ObjCDictionaryElement *Elements,
unsigned NumElements);
@@ -4098,14 +4101,14 @@
ParsedType Ty,
SourceLocation RParenLoc);
- // ParseObjCSelectorExpression - Build selector expression for @selector
+ /// ParseObjCSelectorExpression - Build selector expression for \@selector
ExprResult ParseObjCSelectorExpression(Selector Sel,
SourceLocation AtLoc,
SourceLocation SelLoc,
SourceLocation LParenLoc,
SourceLocation RParenLoc);
- // ParseObjCProtocolExpression - Build protocol expression for @protocol
+ /// ParseObjCProtocolExpression - Build protocol expression for \@protocol
ExprResult ParseObjCProtocolExpression(IdentifierInfo * ProtocolName,
SourceLocation AtLoc,
SourceLocation ProtoLoc,
@@ -4141,7 +4144,7 @@
Declarator &D,
MultiTemplateParamsArg TemplateParameterLists,
Expr *BitfieldWidth, const VirtSpecifiers &VS,
- bool HasDeferredInit);
+ InClassInitStyle InitStyle);
void ActOnCXXInClassMemberInitializer(Decl *VarDecl, SourceLocation EqualLoc,
Expr *Init);
@@ -4865,7 +4868,7 @@
ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
const CXXScopeSpec &SS,
SourceLocation TemplateLoc,
- TemplateTy Template,
+ TemplateTy TemplateName,
SourceLocation TemplateNameLoc,
SourceLocation LAngleLoc,
ASTTemplateArgsPtr TemplateArgs,
@@ -5149,9 +5152,6 @@
/// \param Unexpanded The set of unexpanded parameter packs within the
/// pattern.
///
- /// \param NumUnexpanded The number of unexpanded parameter packs in
- /// \p Unexpanded.
- ///
/// \param ShouldExpand Will be set to \c true if the transformer should
/// expand the corresponding pack expansions into separate arguments. When
/// set, \c NumExpansions must also be set.
@@ -6232,7 +6232,7 @@
POAK_Reset // #pragma options align=reset
};
- /// ActOnPragmaOptionsAlign - Called on well formed #pragma options align.
+ /// ActOnPragmaOptionsAlign - Called on well formed \#pragma options align.
void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind,
SourceLocation PragmaLoc,
SourceLocation KindLoc);
@@ -6249,7 +6249,7 @@
PMSST_ON // #pragms ms_struct on
};
- /// ActOnPragmaPack - Called on well formed #pragma pack(...).
+ /// ActOnPragmaPack - Called on well formed \#pragma pack(...).
void ActOnPragmaPack(PragmaPackKind Kind,
IdentifierInfo *Name,
Expr *Alignment,
@@ -6257,15 +6257,15 @@
SourceLocation LParenLoc,
SourceLocation RParenLoc);
- /// ActOnPragmaMSStruct - Called on well formed #pragms ms_struct [on|off].
+ /// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off].
void ActOnPragmaMSStruct(PragmaMSStructKind Kind);
- /// ActOnPragmaUnused - Called on well-formed '#pragma unused'.
+ /// ActOnPragmaUnused - Called on well-formed '\#pragma unused'.
void ActOnPragmaUnused(const Token &Identifier,
Scope *curScope,
SourceLocation PragmaLoc);
- /// ActOnPragmaVisibility - Called on well formed #pragma GCC visibility... .
+ /// ActOnPragmaVisibility - Called on well formed \#pragma GCC visibility... .
void ActOnPragmaVisibility(const IdentifierInfo* VisType,
SourceLocation PragmaLoc);
@@ -6273,20 +6273,20 @@
SourceLocation Loc);
void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W);
- /// ActOnPragmaWeakID - Called on well formed #pragma weak ident.
+ /// ActOnPragmaWeakID - Called on well formed \#pragma weak ident.
void ActOnPragmaWeakID(IdentifierInfo* WeakName,
SourceLocation PragmaLoc,
SourceLocation WeakNameLoc);
/// ActOnPragmaRedefineExtname - Called on well formed
- /// #pragma redefine_extname oldname newname.
+ /// \#pragma redefine_extname oldname newname.
void ActOnPragmaRedefineExtname(IdentifierInfo* WeakName,
IdentifierInfo* AliasName,
SourceLocation PragmaLoc,
SourceLocation WeakNameLoc,
SourceLocation AliasNameLoc);
- /// ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
+ /// ActOnPragmaWeakAlias - Called on well formed \#pragma weak ident = ident.
void ActOnPragmaWeakAlias(IdentifierInfo* WeakName,
IdentifierInfo* AliasName,
SourceLocation PragmaLoc,
@@ -6294,11 +6294,11 @@
SourceLocation AliasNameLoc);
/// ActOnPragmaFPContract - Called on well formed
- /// #pragma {STDC,OPENCL} FP_CONTRACT
+ /// \#pragma {STDC,OPENCL} FP_CONTRACT
void ActOnPragmaFPContract(tok::OnOffSwitch OOS);
/// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
- /// a the record decl, to handle '#pragma pack' and '#pragma options align'.
+ /// a the record decl, to handle '\#pragma pack' and '\#pragma options align'.
void AddAlignmentAttributesForRecord(RecordDecl *RD);
/// AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
@@ -6312,19 +6312,19 @@
void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
SourceLocation Loc);
- /// AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used,
+ /// AddPushedVisibilityAttribute - If '\#pragma GCC visibility' was used,
/// add an appropriate visibility attribute.
void AddPushedVisibilityAttribute(Decl *RD);
/// PopPragmaVisibility - Pop the top element of the visibility stack; used
- /// for '#pragma GCC visibility' and visibility attributes on namespaces.
+ /// for '\#pragma GCC visibility' and visibility attributes on namespaces.
void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc);
/// FreeVisContext - Deallocate and null out VisContext.
void FreeVisContext();
/// AddCFAuditedAttribute - Check whether we're currently within
- /// '#pragma clang arc_cf_code_audited' and, if so, consider adding
+ /// '\#pragma clang arc_cf_code_audited' and, if so, consider adding
/// the appropriate attribute.
void AddCFAuditedAttribute(Decl *D);
Modified: cfe/branches/tooling/include/clang/Sema/Template.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/Template.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/Template.h (original)
+++ cfe/branches/tooling/include/clang/Sema/Template.h Fri Jun 15 06:08:27 2012
@@ -152,10 +152,11 @@
/// \brief Construct an integral non-type template argument that
/// has been deduced, possibly from an array bound.
- DeducedTemplateArgument(const llvm::APSInt &Value,
+ DeducedTemplateArgument(ASTContext &Ctx,
+ const llvm::APSInt &Value,
QualType ValueType,
bool DeducedFromArrayBound)
- : TemplateArgument(Value, ValueType),
+ : TemplateArgument(Ctx, Value, ValueType),
DeducedFromArrayBound(DeducedFromArrayBound) { }
/// \brief For a non-type template argument, determine whether the
Modified: cfe/branches/tooling/include/clang/Sema/Weak.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/Weak.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/Weak.h (original)
+++ cfe/branches/tooling/include/clang/Sema/Weak.h Fri Jun 15 06:08:27 2012
@@ -21,7 +21,7 @@
class IdentifierInfo;
-/// \brief Captures information about a #pragma weak directive.
+/// \brief Captures information about a \#pragma weak directive.
class WeakInfo {
IdentifierInfo *alias; // alias (optional)
SourceLocation loc; // for diagnostics
Modified: cfe/branches/tooling/include/clang/Serialization/ASTBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Serialization/ASTBitCodes.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/branches/tooling/include/clang/Serialization/ASTBitCodes.h Fri Jun 15 06:08:27 2012
@@ -405,7 +405,7 @@
/// sets.
CXX_BASE_SPECIFIER_OFFSETS = 37,
- /// \brief Record code for #pragma diagnostic mappings.
+ /// \brief Record code for \#pragma diagnostic mappings.
DIAG_PRAGMA_MAPPINGS = 38,
/// \brief Record code for special CUDA declarations.
@@ -417,7 +417,7 @@
/// \brief The directory that the PCH was originally created in.
ORIGINAL_PCH_DIR = 41,
- /// \brief Record code for floating point #pragma options.
+ /// \brief Record code for floating point \#pragma options.
FP_PRAGMA_OPTIONS = 42,
/// \brief Record code for enabled OpenCL extensions.
@@ -441,7 +441,7 @@
MODULE_OFFSET_MAP = 47,
/// \brief Record code for the source manager line table information,
- /// which stores information about #line directives.
+ /// which stores information about \#line directives.
SOURCE_MANAGER_LINE_TABLE = 48,
/// \brief Record code for map of Objective-C class definition IDs to the
@@ -500,8 +500,8 @@
PP_MACRO_OBJECT_LIKE = 1,
/// \brief A function-like macro definition.
- /// [PP_MACRO_FUNCTION_LIKE, <ObjectLikeStuff>, IsC99Varargs, IsGNUVarars,
- /// NumArgs, ArgIdentInfoID* ]
+ /// [PP_MACRO_FUNCTION_LIKE, \<ObjectLikeStuff>, IsC99Varargs,
+ /// IsGNUVarars, NumArgs, ArgIdentInfoID* ]
PP_MACRO_FUNCTION_LIKE = 2,
/// \brief Describes one token.
@@ -1089,7 +1089,7 @@
EXPR_OBJC_MESSAGE_EXPR,
/// \brief An ObjCIsa Expr record.
EXPR_OBJC_ISA,
- /// \breif An ObjCIndirectCopyRestoreExpr record.
+ /// \brief An ObjCIndirectCopyRestoreExpr record.
EXPR_OBJC_INDIRECT_COPY_RESTORE,
/// \brief An ObjCForCollectionStmt record.
Modified: cfe/branches/tooling/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Serialization/ASTReader.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Serialization/ASTReader.h (original)
+++ cfe/branches/tooling/include/clang/Serialization/ASTReader.h Fri Jun 15 06:08:27 2012
@@ -824,19 +824,19 @@
RecordLocation getLocalBitOffset(uint64_t GlobalOffset);
uint64_t getGlobalBitOffset(ModuleFile &M, uint32_t LocalOffset);
- /// \brief Returns the first preprocessed entity ID that ends after \arg BLoc.
+ /// \brief Returns the first preprocessed entity ID that ends after BLoc.
serialization::PreprocessedEntityID
findBeginPreprocessedEntity(SourceLocation BLoc) const;
- /// \brief Returns the first preprocessed entity ID that begins after \arg
- /// ELoc.
+ /// \brief Returns the first preprocessed entity ID that begins after ELoc.
serialization::PreprocessedEntityID
findEndPreprocessedEntity(SourceLocation ELoc) const;
- /// \brief \arg SLocMapI points at a chunk of a module that contains no
- /// preprocessed entities or the entities it contains are not the ones we are
- /// looking for. Find the next module that contains entities and return the ID
+ /// \brief Find the next module that contains entities and return the ID
/// of the first entry.
+ /// \arg SLocMapI points at a chunk of a module that contains no
+ /// preprocessed entities or the entities it contains are not the
+ /// ones we are looking for.
serialization::PreprocessedEntityID
findNextPreprocessedEntity(
GlobalSLocOffsetMapType::const_iterator SLocMapI) const;
Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h Fri Jun 15 06:08:27 2012
@@ -41,8 +41,6 @@
CheckerManager *CheckerMgr;
- enum AnalysisScope { ScopeTU, ScopeDecl } AScope;
-
/// \brief The maximum number of exploded nodes the analyzer will generate.
unsigned MaxNodes;
Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Fri Jun 15 06:08:27 2012
@@ -285,6 +285,10 @@
/// VisitAsmStmt - Transfer function logic for inline asm.
void VisitAsmStmt(const AsmStmt *A, ExplodedNode *Pred, ExplodedNodeSet &Dst);
+
+ /// VisitMSAsmStmt - Transfer function logic for MS inline asm.
+ void VisitMSAsmStmt(const MSAsmStmt *A, ExplodedNode *Pred,
+ ExplodedNodeSet &Dst);
/// VisitBlockExpr - Transfer function logic for BlockExprs.
void VisitBlockExpr(const BlockExpr *BE, ExplodedNode *Pred,
Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Fri Jun 15 06:08:27 2012
@@ -237,8 +237,6 @@
public:
- void dumpToStream(raw_ostream &os) const;
-
static bool classof(const MemRegion *R) {
Kind k = R->getKind();
return k >= BEG_NON_STATIC_GLOBAL_MEMSPACES &&
@@ -308,6 +306,9 @@
HeapSpaceRegion(MemRegionManager *mgr)
: MemSpaceRegion(mgr, HeapSpaceRegionKind) {}
public:
+
+ void dumpToStream(raw_ostream &os) const;
+
static bool classof(const MemRegion *R) {
return R->getKind() == HeapSpaceRegionKind;
}
@@ -319,6 +320,9 @@
UnknownSpaceRegion(MemRegionManager *mgr)
: MemSpaceRegion(mgr, UnknownSpaceRegionKind) {}
public:
+
+ void dumpToStream(raw_ostream &os) const;
+
static bool classof(const MemRegion *R) {
return R->getKind() == UnknownSpaceRegionKind;
}
@@ -352,6 +356,9 @@
StackLocalsSpaceRegion(MemRegionManager *mgr, const StackFrameContext *sfc)
: StackSpaceRegion(mgr, StackLocalsSpaceRegionKind, sfc) {}
public:
+
+ void dumpToStream(raw_ostream &os) const;
+
static bool classof(const MemRegion *R) {
return R->getKind() == StackLocalsSpaceRegionKind;
}
@@ -364,6 +371,9 @@
StackArgumentsSpaceRegion(MemRegionManager *mgr, const StackFrameContext *sfc)
: StackSpaceRegion(mgr, StackArgumentsSpaceRegionKind, sfc) {}
public:
+
+ void dumpToStream(raw_ostream &os) const;
+
static bool classof(const MemRegion *R) {
return R->getKind() == StackArgumentsSpaceRegionKind;
}
@@ -1120,8 +1130,11 @@
const CXXThisRegion *getCXXThisRegion(QualType thisPointerTy,
const LocationContext *LC);
- /// getSymbolicRegion - Retrieve or create a "symbolic" memory region.
- const SymbolicRegion* getSymbolicRegion(SymbolRef sym);
+ /// \brief Retrieve or create a "symbolic" memory region.
+ const SymbolicRegion* getSymbolicRegion(SymbolRef Sym);
+
+ /// \brief Return a unique symbolic region belonging to heap memory space.
+ const SymbolicRegion *getSymbolicHeapRegion(SymbolRef sym);
const StringRegion *getStringRegion(const StringLiteral* Str);
Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h Fri Jun 15 06:08:27 2012
@@ -182,6 +182,12 @@
const LocationContext *LCtx,
QualType type,
unsigned visitCount);
+ /// \brief Conjure a symbol representing heap allocated memory region.
+ ///
+ /// Note, the expression should represent a location.
+ DefinedOrUnknownSVal getConjuredHeapSymbolVal(const Expr *E,
+ const LocationContext *LCtx,
+ unsigned Count);
DefinedOrUnknownSVal getDerivedRegionValueSymbolVal(
SymbolRef parentSymbol, const TypedValueRegion *region);
Propchange: cfe/branches/tooling/include/clang/Tooling/CompilationDatabase.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo (removed)
@@ -1,2 +0,0 @@
-/cfe/branches/type-system-rewrite/include/clang/Tooling/CompilationDatabase.h:134693-134817
-/cfe/trunk/test/SemaTemplate/include/clang/Tooling/CompilationDatabase.h:126920
Propchange: cfe/branches/tooling/include/clang/Tooling/Tooling.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo (removed)
@@ -1,2 +0,0 @@
-/cfe/branches/type-system-rewrite/include/clang/Tooling/Tooling.h:134693-134817
-/cfe/trunk/test/SemaTemplate/include/clang/Tooling/Tooling.h:126920
Modified: cfe/branches/tooling/lib/ARCMigrate/ARCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ARCMigrate/ARCMT.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ARCMigrate/ARCMT.cpp (original)
+++ cfe/branches/tooling/lib/ARCMigrate/ARCMT.cpp Fri Jun 15 06:08:27 2012
@@ -480,13 +480,12 @@
class RewritesApplicator : public TransformActions::RewriteReceiver {
Rewriter &rewriter;
- ASTContext &Ctx;
MigrationProcess::RewriteListener *Listener;
public:
RewritesApplicator(Rewriter &rewriter, ASTContext &ctx,
MigrationProcess::RewriteListener *listener)
- : rewriter(rewriter), Ctx(ctx), Listener(listener) {
+ : rewriter(rewriter), Listener(listener) {
if (Listener)
Listener->start(ctx);
}
Modified: cfe/branches/tooling/lib/ARCMigrate/TransAutoreleasePool.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ARCMigrate/TransAutoreleasePool.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ARCMigrate/TransAutoreleasePool.cpp (original)
+++ cfe/branches/tooling/lib/ARCMigrate/TransAutoreleasePool.cpp Fri Jun 15 06:08:27 2012
@@ -75,7 +75,7 @@
&pass.Ctx.Idents.get("drain"));
}
- void transformBody(Stmt *body) {
+ void transformBody(Stmt *body, Decl *ParentD) {
Body = body;
TraverseStmt(body);
}
Modified: cfe/branches/tooling/lib/ARCMigrate/TransBlockObjCVariable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ARCMigrate/TransBlockObjCVariable.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ARCMigrate/TransBlockObjCVariable.cpp (original)
+++ cfe/branches/tooling/lib/ARCMigrate/TransBlockObjCVariable.cpp Fri Jun 15 06:08:27 2012
@@ -37,7 +37,6 @@
class RootBlockObjCVarRewriter :
public RecursiveASTVisitor<RootBlockObjCVarRewriter> {
- MigrationPass &Pass;
llvm::DenseSet<VarDecl *> &VarsToChange;
class BlockVarChecker : public RecursiveASTVisitor<BlockVarChecker> {
@@ -71,9 +70,8 @@
};
public:
- RootBlockObjCVarRewriter(MigrationPass &pass,
- llvm::DenseSet<VarDecl *> &VarsToChange)
- : Pass(pass), VarsToChange(VarsToChange) { }
+ RootBlockObjCVarRewriter(llvm::DenseSet<VarDecl *> &VarsToChange)
+ : VarsToChange(VarsToChange) { }
bool VisitBlockDecl(BlockDecl *block) {
SmallVector<VarDecl *, 4> BlockVars;
@@ -111,16 +109,14 @@
};
class BlockObjCVarRewriter : public RecursiveASTVisitor<BlockObjCVarRewriter> {
- MigrationPass &Pass;
llvm::DenseSet<VarDecl *> &VarsToChange;
public:
- BlockObjCVarRewriter(MigrationPass &pass,
- llvm::DenseSet<VarDecl *> &VarsToChange)
- : Pass(pass), VarsToChange(VarsToChange) { }
+ BlockObjCVarRewriter(llvm::DenseSet<VarDecl *> &VarsToChange)
+ : VarsToChange(VarsToChange) { }
bool TraverseBlockDecl(BlockDecl *block) {
- RootBlockObjCVarRewriter(Pass, VarsToChange).TraverseDecl(block);
+ RootBlockObjCVarRewriter(VarsToChange).TraverseDecl(block);
return true;
}
};
@@ -131,7 +127,7 @@
MigrationPass &Pass = BodyCtx.getMigrationContext().Pass;
llvm::DenseSet<VarDecl *> VarsToChange;
- BlockObjCVarRewriter trans(Pass, VarsToChange);
+ BlockObjCVarRewriter trans(VarsToChange);
trans.TraverseStmt(BodyCtx.getTopStmt());
for (llvm::DenseSet<VarDecl *>::iterator
Modified: cfe/branches/tooling/lib/ARCMigrate/TransGCCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ARCMigrate/TransGCCalls.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ARCMigrate/TransGCCalls.cpp (original)
+++ cfe/branches/tooling/lib/ARCMigrate/TransGCCalls.cpp Fri Jun 15 06:08:27 2012
@@ -20,13 +20,12 @@
class GCCollectableCallsChecker :
public RecursiveASTVisitor<GCCollectableCallsChecker> {
MigrationContext &MigrateCtx;
- ParentMap &PMap;
IdentifierInfo *NSMakeCollectableII;
IdentifierInfo *CFMakeCollectableII;
public:
- GCCollectableCallsChecker(MigrationContext &ctx, ParentMap &map)
- : MigrateCtx(ctx), PMap(map) {
+ GCCollectableCallsChecker(MigrationContext &ctx)
+ : MigrateCtx(ctx) {
IdentifierTable &Ids = MigrateCtx.Pass.Ctx.Idents;
NSMakeCollectableII = &Ids.get("NSMakeCollectable");
CFMakeCollectableII = &Ids.get("CFMakeCollectable");
@@ -78,7 +77,6 @@
} // anonymous namespace
void GCCollectableCallsTraverser::traverseBody(BodyContext &BodyCtx) {
- GCCollectableCallsChecker(BodyCtx.getMigrationContext(),
- BodyCtx.getParentMap())
+ GCCollectableCallsChecker(BodyCtx.getMigrationContext())
.TraverseStmt(BodyCtx.getTopStmt());
}
Modified: cfe/branches/tooling/lib/ARCMigrate/TransProperties.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ARCMigrate/TransProperties.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ARCMigrate/TransProperties.cpp (original)
+++ cfe/branches/tooling/lib/ARCMigrate/TransProperties.cpp Fri Jun 15 06:08:27 2012
@@ -85,7 +85,7 @@
if (PrevAtProps->find(RawLoc) != PrevAtProps->end())
continue;
PropsTy &props = AtProps[RawLoc];
- props.push_back(&*propI);
+ props.push_back(*propI);
}
}
@@ -102,7 +102,7 @@
for (prop_impl_iterator
I = prop_impl_iterator(D->decls_begin()),
E = prop_impl_iterator(D->decls_end()); I != E; ++I) {
- ObjCPropertyImplDecl *implD = &*I;
+ ObjCPropertyImplDecl *implD = *I;
if (implD->getPropertyImplementation() != ObjCPropertyImplDecl::Synthesize)
continue;
ObjCPropertyDecl *propD = implD->getPropertyDecl();
Modified: cfe/branches/tooling/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ARCMigrate/TransRetainReleaseDealloc.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ARCMigrate/TransRetainReleaseDealloc.cpp (original)
+++ cfe/branches/tooling/lib/ARCMigrate/TransRetainReleaseDealloc.cpp Fri Jun 15 06:08:27 2012
@@ -49,7 +49,7 @@
Pass.Ctx.Selectors.getNullarySelector(&Pass.Ctx.Idents.get("finalize"));
}
- void transformBody(Stmt *body) {
+ void transformBody(Stmt *body, Decl *ParentD) {
Body = body;
collectRemovables(body, Removables);
StmtMap.reset(new ParentMap(body));
Modified: cfe/branches/tooling/lib/ARCMigrate/TransUnbridgedCasts.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ARCMigrate/TransUnbridgedCasts.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ARCMigrate/TransUnbridgedCasts.cpp (original)
+++ cfe/branches/tooling/lib/ARCMigrate/TransUnbridgedCasts.cpp Fri Jun 15 06:08:27 2012
@@ -37,6 +37,7 @@
#include "clang/Analysis/DomainSpecific/CocoaConventions.h"
#include "clang/Sema/SemaDiagnostic.h"
#include "clang/AST/ParentMap.h"
+#include "clang/Lex/Lexer.h"
#include "clang/Basic/SourceManager.h"
#include "llvm/ADT/SmallString.h"
@@ -50,13 +51,15 @@
MigrationPass &Pass;
IdentifierInfo *SelfII;
OwningPtr<ParentMap> StmtMap;
+ Decl *ParentD;
public:
- UnbridgedCastRewriter(MigrationPass &pass) : Pass(pass) {
+ UnbridgedCastRewriter(MigrationPass &pass) : Pass(pass), ParentD(0) {
SelfII = &Pass.Ctx.Idents.get("self");
}
- void transformBody(Stmt *body) {
+ void transformBody(Stmt *body, Decl *ParentD) {
+ this->ParentD = ParentD;
StmtMap.reset(new ParentMap(body));
TraverseStmt(body);
}
@@ -155,6 +158,21 @@
}
}
}
+
+ // If returning an ivar or a member of an ivar from a +0 method, use
+ // a __bridge cast.
+ Expr *base = inner->IgnoreParenImpCasts();
+ while (isa<MemberExpr>(base))
+ base = cast<MemberExpr>(base)->getBase()->IgnoreParenImpCasts();
+ if (isa<ObjCIvarRefExpr>(base) &&
+ isa<ReturnStmt>(StmtMap->getParentIgnoreParenCasts(E))) {
+ if (ObjCMethodDecl *method = dyn_cast_or_null<ObjCMethodDecl>(ParentD)) {
+ if (!method->hasAttr<NSReturnsRetainedAttr>()) {
+ castToObjCObject(E, /*retained=*/false);
+ return;
+ }
+ }
+ }
}
void castToObjCObject(CastExpr *E, bool retained) {
@@ -212,20 +230,26 @@
}
} else {
assert(Kind == OBC_BridgeTransfer || Kind == OBC_BridgeRetained);
- StringRef cfBridging;
+ SmallString<32> BridgeCall;
+
+ Expr *WrapE = E->getSubExpr();
+ SourceLocation InsertLoc = WrapE->getLocStart();
+
+ SourceManager &SM = Pass.Ctx.getSourceManager();
+ char PrevChar = *SM.getCharacterData(InsertLoc.getLocWithOffset(-1));
+ if (Lexer::isIdentifierBodyChar(PrevChar, Pass.Ctx.getLangOpts()))
+ BridgeCall += ' ';
+
if (Kind == OBC_BridgeTransfer)
- cfBridging = "CFBridgingRelease";
+ BridgeCall += "CFBridgingRelease";
else
- cfBridging = "CFBridgingRetain";
+ BridgeCall += "CFBridgingRetain";
- Expr *WrapE = E->getSubExpr();
- SourceLocation insertLoc = WrapE->getLocStart();
if (isa<ParenExpr>(WrapE)) {
- TA.insert(insertLoc, cfBridging);
+ TA.insert(InsertLoc, BridgeCall);
} else {
- std::string withParens = cfBridging;
- withParens += '(';
- TA.insert(insertLoc, withParens);
+ BridgeCall += '(';
+ TA.insert(InsertLoc, BridgeCall);
TA.insertAfterToken(WrapE->getLocEnd(), ")");
}
}
Modified: cfe/branches/tooling/lib/ARCMigrate/TransUnusedInitDelegate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ARCMigrate/TransUnusedInitDelegate.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ARCMigrate/TransUnusedInitDelegate.cpp (original)
+++ cfe/branches/tooling/lib/ARCMigrate/TransUnusedInitDelegate.cpp Fri Jun 15 06:08:27 2012
@@ -40,7 +40,7 @@
UnusedInitRewriter(MigrationPass &pass)
: Body(0), Pass(pass) { }
- void transformBody(Stmt *body) {
+ void transformBody(Stmt *body, Decl *ParentD) {
Body = body;
collectRemovables(body, Removables);
TraverseStmt(body);
Modified: cfe/branches/tooling/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp (original)
+++ cfe/branches/tooling/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp Fri Jun 15 06:08:27 2012
@@ -114,7 +114,7 @@
// this class implementation.
for (ObjCImplDecl::propimpl_iterator
I = IMD->propimpl_begin(), EI = IMD->propimpl_end(); I != EI; ++I) {
- ObjCPropertyImplDecl *PID = &*I;
+ ObjCPropertyImplDecl *PID = *I;
if (PID->getPropertyImplementation() ==
ObjCPropertyImplDecl::Synthesize) {
ObjCPropertyDecl *PD = PID->getPropertyDecl();
Modified: cfe/branches/tooling/lib/ARCMigrate/Transforms.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ARCMigrate/Transforms.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ARCMigrate/Transforms.h (original)
+++ cfe/branches/tooling/lib/ARCMigrate/Transforms.h Fri Jun 15 06:08:27 2012
@@ -13,6 +13,7 @@
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/ParentMap.h"
#include "llvm/ADT/DenseSet.h"
+#include "llvm/Support/SaveAndRestore.h"
namespace clang {
class Decl;
@@ -176,15 +177,22 @@
template <typename BODY_TRANS>
class BodyTransform : public RecursiveASTVisitor<BodyTransform<BODY_TRANS> > {
MigrationPass &Pass;
+ Decl *ParentD;
+ typedef RecursiveASTVisitor<BodyTransform<BODY_TRANS> > base;
public:
- BodyTransform(MigrationPass &pass) : Pass(pass) { }
+ BodyTransform(MigrationPass &pass) : Pass(pass), ParentD(0) { }
bool TraverseStmt(Stmt *rootS) {
if (rootS)
- BODY_TRANS(Pass).transformBody(rootS);
+ BODY_TRANS(Pass).transformBody(rootS, ParentD);
return true;
}
+
+ bool TraverseObjCMethodDecl(ObjCMethodDecl *D) {
+ SaveAndRestore<Decl *> SetParent(ParentD, D);
+ return base::TraverseObjCMethodDecl(D);
+ }
};
typedef llvm::DenseSet<Expr *> ExprSet;
Modified: cfe/branches/tooling/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ASTContext.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ASTContext.cpp (original)
+++ cfe/branches/tooling/lib/AST/ASTContext.cpp Fri Jun 15 06:08:27 2012
@@ -1192,7 +1192,7 @@
if (!leafClass) {
for (ObjCInterfaceDecl::ivar_iterator I = OI->ivar_begin(),
E = OI->ivar_end(); I != E; ++I)
- Ivars.push_back(&*I);
+ Ivars.push_back(*I);
} else {
ObjCInterfaceDecl *IDecl = const_cast<ObjCInterfaceDecl *>(OI);
for (const ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv;
@@ -1342,14 +1342,6 @@
BlockVarCopyInits[VD] = Init;
}
-/// \brief Allocate an uninitialized TypeSourceInfo.
-///
-/// The caller should initialize the memory held by TypeSourceInfo using
-/// the TypeLoc wrappers.
-///
-/// \param T the type that will be the basis for type source info. This type
-/// should refer to how the declarator was written in source code, not to
-/// what type semantic analysis resolved the declarator to.
TypeSourceInfo *ASTContext::CreateTypeSourceInfo(QualType T,
unsigned DataSize) const {
if (!DataSize)
@@ -3336,8 +3328,7 @@
Arg.getNumTemplateExpansions());
case TemplateArgument::Integral:
- return TemplateArgument(*Arg.getAsIntegral(),
- getCanonicalType(Arg.getIntegralType()));
+ return TemplateArgument(Arg, getCanonicalType(Arg.getIntegralType()));
case TemplateArgument::Type:
return TemplateArgument(getCanonicalType(Arg.getAsType()));
@@ -3814,7 +3805,7 @@
FieldTypes[i], /*TInfo=*/0,
/*BitWidth=*/0,
/*Mutable=*/false,
- /*HasInit=*/false);
+ ICIS_NoInit);
Field->setAccess(AS_public);
CFConstantStringTypeDecl->addDecl(Field);
}
@@ -3858,7 +3849,7 @@
FieldTypes[i], /*TInfo=*/0,
/*BitWidth=*/0,
/*Mutable=*/false,
- /*HasInit=*/false);
+ ICIS_NoInit);
Field->setAccess(AS_public);
T->addDecl(Field);
}
@@ -3901,7 +3892,7 @@
FieldTypes[i], /*TInfo=*/0,
/*BitWidth=*/0,
/*Mutable=*/false,
- /*HasInit=*/false);
+ ICIS_NoInit);
Field->setAccess(AS_public);
T->addDecl(Field);
}
@@ -3977,7 +3968,7 @@
&Idents.get(FieldNames[i]),
FieldTypes[i], /*TInfo=*/0,
/*BitWidth=*/0, /*Mutable=*/false,
- /*HasInit=*/false);
+ ICIS_NoInit);
Field->setAccess(AS_public);
T->addDecl(Field);
}
@@ -4232,7 +4223,7 @@
for (ObjCCategoryImplDecl::propimpl_iterator
i = CID->propimpl_begin(), e = CID->propimpl_end();
i != e; ++i) {
- ObjCPropertyImplDecl *PID = &*i;
+ ObjCPropertyImplDecl *PID = *i;
if (PID->getPropertyDecl() == PD) {
if (PID->getPropertyImplementation()==ObjCPropertyImplDecl::Dynamic) {
Dynamic = true;
@@ -4246,7 +4237,7 @@
for (ObjCCategoryImplDecl::propimpl_iterator
i = OID->propimpl_begin(), e = OID->propimpl_end();
i != e; ++i) {
- ObjCPropertyImplDecl *PID = &*i;
+ ObjCPropertyImplDecl *PID = *i;
if (PID->getPropertyDecl() == PD) {
if (PID->getPropertyImplementation()==ObjCPropertyImplDecl::Dynamic) {
Dynamic = true;
@@ -4568,7 +4559,7 @@
// Special case bit-fields.
if (Field->isBitField()) {
getObjCEncodingForTypeImpl(Field->getType(), S, false, true,
- &*Field);
+ *Field);
} else {
QualType qt = Field->getType();
getLegacyIntegralTypeEncoding(qt);
@@ -4764,7 +4755,7 @@
Field != FieldEnd; ++Field, ++i) {
uint64_t offs = layout.getFieldOffset(i);
FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
- std::make_pair(offs, &*Field));
+ std::make_pair(offs, *Field));
}
if (CXXRec && includeVBases) {
@@ -6414,6 +6405,19 @@
VectorType::GenericVector);
break;
}
+ case 'E': {
+ char *End;
+
+ unsigned NumElements = strtoul(Str, &End, 10);
+ assert(End != Str && "Missing vector size");
+
+ Str = End;
+
+ QualType ElementType = DecodeTypeFromStr(Str, Context, Error, RequiresICE,
+ false);
+ Type = Context.getExtVectorType(ElementType, NumElements);
+ break;
+ }
case 'X': {
QualType ElementType = DecodeTypeFromStr(Str, Context, Error, RequiresICE,
false);
Modified: cfe/branches/tooling/lib/AST/ASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ASTImporter.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ASTImporter.cpp (original)
+++ cfe/branches/tooling/lib/AST/ASTImporter.cpp Fri Jun 15 06:08:27 2012
@@ -322,7 +322,7 @@
Arg2.getIntegralType()))
return false;
- return IsSameValue(*Arg1.getAsIntegral(), *Arg2.getAsIntegral());
+ return IsSameValue(Arg1.getAsIntegral(), Arg2.getAsIntegral());
case TemplateArgument::Declaration:
if (!Arg1.getAsDecl() || !Arg2.getAsDecl())
@@ -1017,7 +1017,7 @@
return false;
}
- if (!IsStructurallyEquivalent(Context, &*Field1, &*Field2))
+ if (!IsStructurallyEquivalent(Context, *Field1, *Field2))
return false;
}
@@ -1858,14 +1858,8 @@
= FromData.HasConstexprNonCopyMoveConstructor;
ToData.DefaultedDefaultConstructorIsConstexpr
= FromData.DefaultedDefaultConstructorIsConstexpr;
- ToData.DefaultedCopyConstructorIsConstexpr
- = FromData.DefaultedCopyConstructorIsConstexpr;
- ToData.DefaultedMoveConstructorIsConstexpr
- = FromData.DefaultedMoveConstructorIsConstexpr;
ToData.HasConstexprDefaultConstructor
= FromData.HasConstexprDefaultConstructor;
- ToData.HasConstexprCopyConstructor = FromData.HasConstexprCopyConstructor;
- ToData.HasConstexprMoveConstructor = FromData.HasConstexprMoveConstructor;
ToData.HasTrivialCopyConstructor = FromData.HasTrivialCopyConstructor;
ToData.HasTrivialMoveConstructor = FromData.HasTrivialMoveConstructor;
ToData.HasTrivialCopyAssignment = FromData.HasTrivialCopyAssignment;
@@ -1992,7 +1986,7 @@
QualType ToType = Importer.Import(From.getIntegralType());
if (ToType.isNull())
return TemplateArgument();
- return TemplateArgument(*From.getAsIntegral(), ToType);
+ return TemplateArgument(From, ToType);
}
case TemplateArgument::Declaration:
@@ -2662,7 +2656,7 @@
Importer.Import(D->getInnerLocStart()),
Loc, Name.getAsIdentifierInfo(),
T, TInfo, BitWidth, D->isMutable(),
- D->hasInClassInitializer());
+ D->getInClassInitStyle());
ToField->setAccess(D->getAccess());
ToField->setLexicalDeclContext(LexicalDC);
if (ToField->hasInClassInitializer())
Modified: cfe/branches/tooling/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/Decl.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/Decl.cpp (original)
+++ cfe/branches/tooling/lib/AST/Decl.cpp Fri Jun 15 06:08:27 2012
@@ -381,7 +381,7 @@
LinkageInfo ArgsLV = getLVForTemplateArgumentList(templateArgs,
OnlyTemplate);
if (shouldConsiderTemplateVis(Function, specInfo)) {
- LV.merge(TempLV);
+ LV.mergeWithMin(TempLV);
LV.mergeWithMin(ArgsLV);
} else {
LV.mergeLinkage(TempLV);
@@ -412,7 +412,7 @@
LinkageInfo ArgsLV = getLVForTemplateArgumentList(TemplateArgs,
OnlyTemplate);
if (shouldConsiderTemplateVis(spec)) {
- LV.merge(TempLV);
+ LV.mergeWithMin(TempLV);
LV.mergeWithMin(ArgsLV);
} else {
LV.mergeLinkage(TempLV);
@@ -544,7 +544,7 @@
if (shouldConsiderTemplateVis(MD, spec)) {
LV.mergeWithMin(ArgsLV);
if (!OnlyTemplate)
- LV.merge(ParamsLV);
+ LV.mergeWithMin(ParamsLV);
} else {
LV.mergeLinkage(ArgsLV);
if (!OnlyTemplate)
@@ -569,7 +569,7 @@
if (shouldConsiderTemplateVis(spec)) {
LV.mergeWithMin(ArgsLV);
if (!OnlyTemplate)
- LV.merge(ParamsLV);
+ LV.mergeWithMin(ParamsLV);
} else {
LV.mergeLinkage(ArgsLV);
if (!OnlyTemplate)
@@ -1684,6 +1684,13 @@
Parent->markedVirtualFunctionPure();
}
+void FunctionDecl::setConstexpr(bool IC) {
+ IsConstexpr = IC;
+ CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(this);
+ if (IC && CD)
+ CD->getParent()->markedConstructorConstexpr(CD);
+}
+
bool FunctionDecl::isMain() const {
const TranslationUnitDecl *tunit =
dyn_cast<TranslationUnitDecl>(getDeclContext()->getRedeclContext());
@@ -2458,15 +2465,15 @@
SourceLocation StartLoc, SourceLocation IdLoc,
IdentifierInfo *Id, QualType T,
TypeSourceInfo *TInfo, Expr *BW, bool Mutable,
- bool HasInit) {
+ InClassInitStyle InitStyle) {
return new (C) FieldDecl(Decl::Field, DC, StartLoc, IdLoc, Id, T, TInfo,
- BW, Mutable, HasInit);
+ BW, Mutable, InitStyle);
}
FieldDecl *FieldDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
void *Mem = AllocateDeserializedDecl(C, ID, sizeof(FieldDecl));
return new (Mem) FieldDecl(Field, 0, SourceLocation(), SourceLocation(),
- 0, QualType(), 0, 0, false, false);
+ 0, QualType(), 0, 0, false, ICIS_NoInit);
}
bool FieldDecl::isAnonymousStructOrUnion() const {
@@ -2499,11 +2506,11 @@
if (IsMsStruct) {
// Zero-length bitfields following non-bitfield members are ignored.
- if (getASTContext().ZeroBitfieldFollowsNonBitfield(&*I, LastFD)) {
+ if (getASTContext().ZeroBitfieldFollowsNonBitfield(*I, LastFD)) {
--Index;
continue;
}
- LastFD = &*I;
+ LastFD = *I;
}
}
@@ -2518,10 +2525,9 @@
}
void FieldDecl::setInClassInitializer(Expr *Init) {
- assert(!InitializerOrBitWidth.getPointer() &&
+ assert(!InitializerOrBitWidth.getPointer() && hasInClassInitializer() &&
"bit width or initializer already set");
InitializerOrBitWidth.setPointer(Init);
- InitializerOrBitWidth.setInt(0);
}
//===----------------------------------------------------------------------===//
Modified: cfe/branches/tooling/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/DeclBase.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/DeclBase.cpp (original)
+++ cfe/branches/tooling/lib/AST/DeclBase.cpp Fri Jun 15 06:08:27 2012
@@ -974,10 +974,6 @@
return decl_iterator(FirstDecl);
}
-DeclContext::decl_iterator DeclContext::noload_decls_end() const {
- return decl_iterator();
-}
-
DeclContext::decl_iterator DeclContext::decls_begin() const {
if (hasExternalLexicalStorage())
LoadLexicalDeclsFromExternalStorage();
@@ -985,13 +981,6 @@
return decl_iterator(FirstDecl);
}
-DeclContext::decl_iterator DeclContext::decls_end() const {
- if (hasExternalLexicalStorage())
- LoadLexicalDeclsFromExternalStorage();
-
- return decl_iterator();
-}
-
bool DeclContext::decls_empty() const {
if (hasExternalLexicalStorage())
LoadLexicalDeclsFromExternalStorage();
Modified: cfe/branches/tooling/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/DeclCXX.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/DeclCXX.cpp (original)
+++ cfe/branches/tooling/lib/AST/DeclCXX.cpp Fri Jun 15 06:08:27 2012
@@ -47,10 +47,7 @@
HasTrivialDefaultConstructor(true),
HasConstexprNonCopyMoveConstructor(false),
DefaultedDefaultConstructorIsConstexpr(true),
- DefaultedCopyConstructorIsConstexpr(true),
- DefaultedMoveConstructorIsConstexpr(true),
- HasConstexprDefaultConstructor(false), HasConstexprCopyConstructor(false),
- HasConstexprMoveConstructor(false), HasTrivialCopyConstructor(true),
+ HasConstexprDefaultConstructor(false), HasTrivialCopyConstructor(true),
HasTrivialMoveConstructor(true), HasTrivialCopyAssignment(true),
HasTrivialMoveAssignment(true), HasTrivialDestructor(true),
HasIrrelevantDestructor(true),
@@ -220,8 +217,6 @@
// In the definition of a constexpr constructor [...]
// -- the class shall not have any virtual base classes
data().DefaultedDefaultConstructorIsConstexpr = false;
- data().DefaultedCopyConstructorIsConstexpr = false;
- data().DefaultedMoveConstructorIsConstexpr = false;
} else {
// C++ [class.ctor]p5:
// A default constructor is trivial [...] if:
@@ -260,25 +255,6 @@
// default constructor is constexpr.
if (!BaseClassDecl->hasConstexprDefaultConstructor())
data().DefaultedDefaultConstructorIsConstexpr = false;
-
- // C++11 [class.copy]p13:
- // If the implicitly-defined constructor would satisfy the requirements
- // of a constexpr constructor, the implicitly-defined constructor is
- // constexpr.
- // C++11 [dcl.constexpr]p4:
- // -- every constructor involved in initializing [...] base class
- // sub-objects shall be a constexpr constructor
- if (!BaseClassDecl->hasConstexprCopyConstructor())
- data().DefaultedCopyConstructorIsConstexpr = false;
- if (BaseClassDecl->hasDeclaredMoveConstructor() ||
- BaseClassDecl->needsImplicitMoveConstructor())
- // FIXME: If the implicit move constructor generated for the base class
- // would be ill-formed, the implicit move constructor generated for the
- // derived class calls the base class' copy constructor.
- data().DefaultedMoveConstructorIsConstexpr &=
- BaseClassDecl->hasConstexprMoveConstructor();
- else if (!BaseClassDecl->hasConstexprCopyConstructor())
- data().DefaultedMoveConstructorIsConstexpr = false;
}
// C++ [class.ctor]p3:
@@ -401,7 +377,7 @@
CXXConstructorDecl *CXXRecordDecl::getMoveConstructor() const {
for (ctor_iterator I = ctor_begin(), E = ctor_end(); I != E; ++I)
if (I->isMoveConstructor())
- return &*I;
+ return *I;
return 0;
}
@@ -459,7 +435,7 @@
CXXMethodDecl *CXXRecordDecl::getMoveAssignmentOperator() const {
for (method_iterator I = method_begin(), E = method_end(); I != E; ++I)
if (I->isMoveAssignmentOperator())
- return &*I;
+ return *I;
return 0;
}
@@ -470,6 +446,14 @@
data().Abstract = true;
}
+void CXXRecordDecl::markedConstructorConstexpr(CXXConstructorDecl *CD) {
+ if (!CD->isCopyOrMoveConstructor())
+ data().HasConstexprNonCopyMoveConstructor = true;
+
+ if (CD->isDefaultConstructor())
+ data().HasConstexprDefaultConstructor = true;
+}
+
void CXXRecordDecl::addedMember(Decl *D) {
if (!D->isImplicit() &&
!isa<FieldDecl>(D) &&
@@ -546,12 +530,8 @@
}
} else if (Constructor->isCopyConstructor()) {
data().DeclaredCopyConstructor = true;
- if (Constructor->isConstexpr())
- data().HasConstexprCopyConstructor = true;
} else if (Constructor->isMoveConstructor()) {
data().DeclaredMoveConstructor = true;
- if (Constructor->isConstexpr())
- data().HasConstexprMoveConstructor = true;
} else
goto NotASpecialMember;
return;
@@ -608,9 +588,6 @@
// user-provided [...]
if (UserProvided)
data().HasTrivialCopyConstructor = false;
-
- if (Constructor->isConstexpr())
- data().HasConstexprCopyConstructor = true;
} else if (Constructor->isMoveConstructor()) {
data().UserDeclaredMoveConstructor = true;
data().DeclaredMoveConstructor = true;
@@ -620,9 +597,6 @@
// user-provided [...]
if (UserProvided)
data().HasTrivialMoveConstructor = false;
-
- if (Constructor->isConstexpr())
- data().HasConstexprMoveConstructor = true;
}
}
if (Constructor->isConstexpr() && !Constructor->isCopyOrMoveConstructor()) {
@@ -664,19 +638,9 @@
// C++11 [class.dtor]p5:
// A destructor is trivial if it is not user-provided and if
// -- the destructor is not virtual.
- if (DD->isUserProvided() || DD->isVirtual()) {
+ if (DD->isUserProvided() || DD->isVirtual())
data().HasTrivialDestructor = false;
- // C++11 [dcl.constexpr]p1:
- // The constexpr specifier shall be applied only to [...] the
- // declaration of a static data member of a literal type.
- // C++11 [basic.types]p10:
- // A type is a literal type if it is [...] a class type that [...] has
- // a trivial destructor.
- data().DefaultedDefaultConstructorIsConstexpr = false;
- data().DefaultedCopyConstructorIsConstexpr = false;
- data().DefaultedMoveConstructorIsConstexpr = false;
- }
-
+
return;
}
@@ -927,27 +891,11 @@
// The standard requires any in-class initializer to be a constant
// expression. We consider this to be a defect.
data().DefaultedDefaultConstructorIsConstexpr = false;
-
- if (!FieldRec->hasConstexprCopyConstructor())
- data().DefaultedCopyConstructorIsConstexpr = false;
-
- if (FieldRec->hasDeclaredMoveConstructor() ||
- FieldRec->needsImplicitMoveConstructor())
- // FIXME: If the implicit move constructor generated for the member's
- // class would be ill-formed, the implicit move constructor generated
- // for this class calls the member's copy constructor.
- data().DefaultedMoveConstructorIsConstexpr &=
- FieldRec->hasConstexprMoveConstructor();
- else if (!FieldRec->hasConstexprCopyConstructor())
- data().DefaultedMoveConstructorIsConstexpr = false;
}
} else {
// Base element type of field is a non-class type.
- if (!T->isLiteralType()) {
- data().DefaultedDefaultConstructorIsConstexpr = false;
- data().DefaultedCopyConstructorIsConstexpr = false;
- data().DefaultedMoveConstructorIsConstexpr = false;
- } else if (!Field->hasInClassInitializer() && !isUnion())
+ if (!T->isLiteralType() ||
+ (!Field->hasInClassInitializer() && !isUnion()))
data().DefaultedDefaultConstructorIsConstexpr = false;
}
@@ -999,11 +947,11 @@
for (LambdaExpr::Capture *C = Lambda.Captures, *CEnd = C + Lambda.NumCaptures;
C != CEnd; ++C, ++Field) {
if (C->capturesThis()) {
- ThisCapture = &*Field;
+ ThisCapture = *Field;
continue;
}
- Captures[C->getCapturedVar()] = &*Field;
+ Captures[C->getCapturedVar()] = *Field;
}
}
Modified: cfe/branches/tooling/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/DeclObjC.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/DeclObjC.cpp (original)
+++ cfe/branches/tooling/lib/AST/DeclObjC.cpp Fri Jun 15 06:08:27 2012
@@ -767,9 +767,9 @@
ObjCIvarDecl *curIvar = 0;
if (!ivar_empty()) {
ObjCInterfaceDecl::ivar_iterator I = ivar_begin(), E = ivar_end();
- data().IvarList = &*I; ++I;
- for (curIvar = data().IvarList; I != E; curIvar = &*I, ++I)
- curIvar->setNextIvar(&*I);
+ data().IvarList = *I; ++I;
+ for (curIvar = data().IvarList; I != E; curIvar = *I, ++I)
+ curIvar->setNextIvar(*I);
}
for (const ObjCCategoryDecl *CDecl = getFirstClassExtension(); CDecl;
@@ -778,11 +778,11 @@
ObjCCategoryDecl::ivar_iterator I = CDecl->ivar_begin(),
E = CDecl->ivar_end();
if (!data().IvarList) {
- data().IvarList = &*I; ++I;
+ data().IvarList = *I; ++I;
curIvar = data().IvarList;
}
- for ( ;I != E; curIvar = &*I, ++I)
- curIvar->setNextIvar(&*I);
+ for ( ;I != E; curIvar = *I, ++I)
+ curIvar->setNextIvar(*I);
}
}
@@ -791,11 +791,11 @@
ObjCImplementationDecl::ivar_iterator I = ImplDecl->ivar_begin(),
E = ImplDecl->ivar_end();
if (!data().IvarList) {
- data().IvarList = &*I; ++I;
+ data().IvarList = *I; ++I;
curIvar = data().IvarList;
}
- for ( ;I != E; curIvar = &*I, ++I)
- curIvar->setNextIvar(&*I);
+ for ( ;I != E; curIvar = *I, ++I)
+ curIvar->setNextIvar(*I);
}
}
return data().IvarList;
@@ -1175,7 +1175,7 @@
ObjCPropertyImplDecl *ObjCImplDecl::
FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const {
for (propimpl_iterator i = propimpl_begin(), e = propimpl_end(); i != e; ++i){
- ObjCPropertyImplDecl *PID = &*i;
+ ObjCPropertyImplDecl *PID = *i;
if (PID->getPropertyIvarDecl() &&
PID->getPropertyIvarDecl()->getIdentifier() == ivarId)
return PID;
@@ -1190,7 +1190,7 @@
ObjCPropertyImplDecl *ObjCImplDecl::
FindPropertyImplDecl(IdentifierInfo *Id) const {
for (propimpl_iterator i = propimpl_begin(), e = propimpl_end(); i != e; ++i){
- ObjCPropertyImplDecl *PID = &*i;
+ ObjCPropertyImplDecl *PID = *i;
if (PID->getPropertyDecl()->getIdentifier() == Id)
return PID;
}
Modified: cfe/branches/tooling/lib/AST/DeclPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/DeclPrinter.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/DeclPrinter.cpp (original)
+++ cfe/branches/tooling/lib/AST/DeclPrinter.cpp Fri Jun 15 06:08:27 2012
@@ -582,7 +582,10 @@
Expr *Init = D->getInClassInitializer();
if (!Policy.SuppressInitializers && Init) {
- Out << " = ";
+ if (D->getInClassInitStyle() == ICIS_ListInit)
+ Out << " ";
+ else
+ Out << " = ";
Init->printPretty(Out, Context, 0, Policy, Indentation);
}
prettyPrintAttributes(D);
@@ -913,7 +916,7 @@
Indentation += Policy.Indentation;
for (ObjCInterfaceDecl::ivar_iterator I = OID->ivar_begin(),
E = OID->ivar_end(); I != E; ++I) {
- Indent() << I->getType().getAsString(Policy) << ' ' << *I << ";\n";
+ Indent() << I->getType().getAsString(Policy) << ' ' << **I << ";\n";
}
Indentation -= Policy.Indentation;
Out << "}\n";
Modified: cfe/branches/tooling/lib/AST/DumpXML.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/DumpXML.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/DumpXML.cpp (original)
+++ cfe/branches/tooling/lib/AST/DumpXML.cpp Fri Jun 15 06:08:27 2012
@@ -326,7 +326,7 @@
}
case TemplateArgument::Integral: {
push("integer");
- setInteger("value", *A.getAsIntegral());
+ setInteger("value", A.getAsIntegral());
completeAttrs();
pop();
break;
Modified: cfe/branches/tooling/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/Expr.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/Expr.cpp (original)
+++ cfe/branches/tooling/lib/AST/Expr.cpp Fri Jun 15 06:08:27 2012
@@ -633,6 +633,99 @@
return SL;
}
+void StringLiteral::outputString(raw_ostream &OS) {
+ switch (getKind()) {
+ case Ascii: break; // no prefix.
+ case Wide: OS << 'L'; break;
+ case UTF8: OS << "u8"; break;
+ case UTF16: OS << 'u'; break;
+ case UTF32: OS << 'U'; break;
+ }
+ OS << '"';
+ static const char Hex[] = "0123456789ABCDEF";
+
+ unsigned LastSlashX = getLength();
+ for (unsigned I = 0, N = getLength(); I != N; ++I) {
+ switch (uint32_t Char = getCodeUnit(I)) {
+ default:
+ // FIXME: Convert UTF-8 back to codepoints before rendering.
+
+ // Convert UTF-16 surrogate pairs back to codepoints before rendering.
+ // Leave invalid surrogates alone; we'll use \x for those.
+ if (getKind() == UTF16 && I != N - 1 && Char >= 0xd800 &&
+ Char <= 0xdbff) {
+ uint32_t Trail = getCodeUnit(I + 1);
+ if (Trail >= 0xdc00 && Trail <= 0xdfff) {
+ Char = 0x10000 + ((Char - 0xd800) << 10) + (Trail - 0xdc00);
+ ++I;
+ }
+ }
+
+ if (Char > 0xff) {
+ // If this is a wide string, output characters over 0xff using \x
+ // escapes. Otherwise, this is a UTF-16 or UTF-32 string, and Char is a
+ // codepoint: use \x escapes for invalid codepoints.
+ if (getKind() == Wide ||
+ (Char >= 0xd800 && Char <= 0xdfff) || Char >= 0x110000) {
+ // FIXME: Is this the best way to print wchar_t?
+ OS << "\\x";
+ int Shift = 28;
+ while ((Char >> Shift) == 0)
+ Shift -= 4;
+ for (/**/; Shift >= 0; Shift -= 4)
+ OS << Hex[(Char >> Shift) & 15];
+ LastSlashX = I;
+ break;
+ }
+
+ if (Char > 0xffff)
+ OS << "\\U00"
+ << Hex[(Char >> 20) & 15]
+ << Hex[(Char >> 16) & 15];
+ else
+ OS << "\\u";
+ OS << Hex[(Char >> 12) & 15]
+ << Hex[(Char >> 8) & 15]
+ << Hex[(Char >> 4) & 15]
+ << Hex[(Char >> 0) & 15];
+ break;
+ }
+
+ // If we used \x... for the previous character, and this character is a
+ // hexadecimal digit, prevent it being slurped as part of the \x.
+ if (LastSlashX + 1 == I) {
+ switch (Char) {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+ OS << "\"\"";
+ }
+ }
+
+ assert(Char <= 0xff &&
+ "Characters above 0xff should already have been handled.");
+
+ if (isprint(Char))
+ OS << (char)Char;
+ else // Output anything hard as an octal escape.
+ OS << '\\'
+ << (char)('0' + ((Char >> 6) & 7))
+ << (char)('0' + ((Char >> 3) & 7))
+ << (char)('0' + ((Char >> 0) & 7));
+ break;
+ // Handle some common non-printable cases to make dumps prettier.
+ case '\\': OS << "\\\\"; break;
+ case '"': OS << "\\\""; break;
+ case '\n': OS << "\\n"; break;
+ case '\t': OS << "\\t"; break;
+ case '\a': OS << "\\a"; break;
+ case '\b': OS << "\\b"; break;
+ }
+ }
+ OS << '"';
+}
+
void StringLiteral::setString(ASTContext &C, StringRef Str,
StringKind Kind, bool IsPascal) {
//FIXME: we assume that the string data comes from a target that uses the same
@@ -679,7 +772,8 @@
SourceLocation StringLiteral::
getLocationOfByte(unsigned ByteNo, const SourceManager &SM,
const LangOptions &Features, const TargetInfo &Target) const {
- assert(Kind == StringLiteral::Ascii && "This only works for ASCII strings");
+ assert((Kind == StringLiteral::Ascii || Kind == StringLiteral::UTF8) &&
+ "Only narrow string literals are currently supported");
// Loop over all of the tokens in this string until we find the one that
// contains the byte we're looking for.
@@ -702,11 +796,6 @@
const char *StrData = Buffer.data()+LocInfo.second;
- // Create a langops struct and enable trigraphs. This is sufficient for
- // relexing tokens.
- LangOptions LangOpts;
- LangOpts.Trigraphs = true;
-
// Create a lexer starting at the beginning of this token.
Lexer TheLexer(SM.getLocForStartOfFile(LocInfo.first), Features,
Buffer.begin(), StrData, Buffer.end());
Modified: cfe/branches/tooling/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ExprConstant.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ExprConstant.cpp (original)
+++ cfe/branches/tooling/lib/AST/ExprConstant.cpp Fri Jun 15 06:08:27 2012
@@ -3418,7 +3418,7 @@
continue;
LValue Subobject = This;
- if (!HandleLValueMember(Info, E, Subobject, &*I, &Layout))
+ if (!HandleLValueMember(Info, E, Subobject, *I, &Layout))
return false;
ImplicitValueInitExpr VIE(I->getType());
@@ -3443,9 +3443,9 @@
}
LValue Subobject = This;
- if (!HandleLValueMember(Info, E, Subobject, &*I))
+ if (!HandleLValueMember(Info, E, Subobject, *I))
return false;
- Result = APValue(&*I);
+ Result = APValue(*I);
ImplicitValueInitExpr VIE(I->getType());
return EvaluateInPlace(Result.getUnionValue(), Info, Subobject, &VIE);
}
@@ -3536,7 +3536,7 @@
// FIXME: Diagnostics here should point to the end of the initializer
// list, not the start.
if (!HandleLValueMember(Info, HaveInit ? E->getInit(ElementNo) : E,
- Subobject, &*Field, &Layout))
+ Subobject, *Field, &Layout))
return false;
// Perform an implicit value-initialization for members beyond the end of
Modified: cfe/branches/tooling/lib/AST/ItaniumMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ItaniumMangle.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/branches/tooling/lib/AST/ItaniumMangle.cpp Fri Jun 15 06:08:27 2012
@@ -1032,17 +1032,14 @@
for (RecordDecl::field_iterator I = RD->field_begin(), E = RD->field_end();
I != E; ++I) {
- const FieldDecl *FD = &*I;
+ if (I->getIdentifier())
+ return *I;
- if (FD->getIdentifier())
- return FD;
-
- if (const RecordType *RT = FD->getType()->getAs<RecordType>()) {
+ if (const RecordType *RT = I->getType()->getAs<RecordType>())
if (const FieldDecl *NamedDataMember =
FindFirstNamedDataMember(RT->getDecl()))
return NamedDataMember;
}
- }
// We didn't find a named data member.
return 0;
@@ -3135,7 +3132,7 @@
break;
}
case TemplateArgument::Integral:
- mangleIntegerLiteral(A.getIntegralType(), *A.getAsIntegral());
+ mangleIntegerLiteral(A.getIntegralType(), A.getAsIntegral());
break;
case TemplateArgument::Declaration: {
assert(P && "Missing template parameter for declaration argument");
Modified: cfe/branches/tooling/lib/AST/MicrosoftMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/MicrosoftMangle.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/branches/tooling/lib/AST/MicrosoftMangle.cpp Fri Jun 15 06:08:27 2012
@@ -37,13 +37,15 @@
MicrosoftCXXNameMangler(MangleContext &C, raw_ostream &Out_)
: Context(C), Out(Out_) { }
- void mangle(const NamedDecl *D, StringRef Prefix = "?");
+ raw_ostream &getStream() const { return Out; }
+
+ void mangle(const NamedDecl *D, StringRef Prefix = "\01?");
void mangleName(const NamedDecl *ND);
void mangleFunctionEncoding(const FunctionDecl *FD);
void mangleVariableEncoding(const VarDecl *VD);
void mangleNumber(int64_t Number);
void mangleNumber(const llvm::APSInt &Value);
- void mangleType(QualType T);
+ void mangleType(QualType T, SourceRange Range);
private:
void mangleUnqualifiedName(const NamedDecl *ND) {
@@ -52,21 +54,24 @@
void mangleUnqualifiedName(const NamedDecl *ND, DeclarationName Name);
void mangleSourceName(const IdentifierInfo *II);
void manglePostfix(const DeclContext *DC, bool NoFunction=false);
- void mangleOperatorName(OverloadedOperatorKind OO);
+ void mangleOperatorName(OverloadedOperatorKind OO, SourceLocation Loc);
void mangleQualifiers(Qualifiers Quals, bool IsMember);
void mangleUnscopedTemplateName(const TemplateDecl *ND);
void mangleTemplateInstantiationName(const TemplateDecl *TD,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs,
- SourceLocation InstantiationLoc);
+ const SmallVectorImpl<TemplateArgumentLoc> &TemplateArgs);
void mangleObjCMethodName(const ObjCMethodDecl *MD);
+ void mangleLocalName(const FunctionDecl *FD);
// Declare manglers for every type class.
#define ABSTRACT_TYPE(CLASS, PARENT)
#define NON_CANONICAL_TYPE(CLASS, PARENT)
-#define TYPE(CLASS, PARENT) void mangleType(const CLASS##Type *T);
+#define TYPE(CLASS, PARENT) void mangleType(const CLASS##Type *T, \
+ SourceRange Range);
#include "clang/AST/TypeNodes.def"
+#undef ABSTRACT_TYPE
+#undef NON_CANONICAL_TYPE
+#undef TYPE
void mangleType(const TagType*);
void mangleType(const FunctionType *T, const FunctionDecl *D,
@@ -78,8 +83,8 @@
void mangleIntegerLiteral(QualType T, const llvm::APSInt &Number);
void mangleThrowSpecification(const FunctionProtoType *T);
- void mangleTemplateArgs(const TemplateArgument *TemplateArgs, unsigned NumTemplateArgs,
- SourceLocation InstantiationLoc);
+ void mangleTemplateArgs(
+ const SmallVectorImpl<TemplateArgumentLoc> &TemplateArgs);
};
@@ -167,15 +172,15 @@
StringRef Prefix) {
// MSVC doesn't mangle C++ names the same way it mangles extern "C" names.
// Therefore it's really important that we don't decorate the
- // name with leading underscores or leading/trailing at signs. So, emit a
- // asm marker at the start so we get the name right.
- Out << '\01'; // LLVM IR Marker for __asm("foo")
+ // name with leading underscores or leading/trailing at signs. So, by
+ // default, we emit an asm marker at the start so we get the name right.
+ // Callers can override this with a custom prefix.
// Any decl can be declared with __asm("foo") on it, and this takes precedence
// over all other naming in the .o file.
if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>()) {
// If we have an asm name, then we use it as the mangling.
- Out << ALA->getLabel();
+ Out << '\01' << ALA->getLabel();
return;
}
@@ -186,7 +191,15 @@
mangleFunctionEncoding(FD);
else if (const VarDecl *VD = dyn_cast<VarDecl>(D))
mangleVariableEncoding(VD);
- // TODO: Fields? Can MSVC even mangle them?
+ else {
+ // TODO: Fields? Can MSVC even mangle them?
+ // Issue a diagnostic for now.
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this declaration yet");
+ Diags.Report(D->getLocation(), DiagID)
+ << D->getSourceRange();
+ }
}
void MicrosoftCXXNameMangler::mangleFunctionEncoding(const FunctionDecl *FD) {
@@ -242,16 +255,17 @@
// ::= <type> A # pointers, references, arrays
// Pointers and references are odd. The type of 'int * const foo;' gets
// mangled as 'QAHA' instead of 'PAHB', for example.
- QualType Ty = VD->getType();
+ TypeLoc TL = VD->getTypeSourceInfo()->getTypeLoc();
+ QualType Ty = TL.getType();
if (Ty->isPointerType() || Ty->isReferenceType()) {
- mangleType(Ty);
+ mangleType(Ty, TL.getSourceRange());
Out << 'A';
- } else if (Ty->isArrayType()) {
+ } else if (const ArrayType *AT = getASTContext().getAsArrayType(Ty)) {
// Global arrays are funny, too.
- mangleType(cast<ArrayType>(Ty.getTypePtr()), true);
+ mangleType(AT, true);
Out << 'A';
} else {
- mangleType(Ty.getLocalUnqualifiedType());
+ mangleType(Ty.getLocalUnqualifiedType(), TL.getSourceRange());
mangleQualifiers(Ty.getLocalQualifiers(), false);
}
}
@@ -283,8 +297,8 @@
Out << '?';
Number = -Number;
}
- // Oddly enough, there's a special shorter mangling for 0, but Microsoft chose not
- // to use it. Instead, 0 gets mangled as "A@". Oh well...
+ // There's a special shorter mangling for 0, but Microsoft
+ // chose not to use it. Instead, 0 gets mangled as "A@". Oh well...
if (Number >= 1 && Number <= 10)
Out << Number-1;
else {
@@ -323,18 +337,32 @@
for (int i = 0, e = Value.getActiveBits() / 4; i != e; ++i) {
*--CurPtr = 'A' + Temp.And(NibbleMask).getLimitedValue(0xf);
Temp = Temp.lshr(4);
- };
+ }
Out.write(CurPtr, EndPtr-CurPtr);
Out << '@';
}
}
static const TemplateDecl *
-isTemplate(const NamedDecl *ND, const TemplateArgumentList *&TemplateArgs) {
+isTemplate(const NamedDecl *ND,
+ SmallVectorImpl<TemplateArgumentLoc> &TemplateArgs) {
// Check if we have a function template.
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)){
if (const TemplateDecl *TD = FD->getPrimaryTemplate()) {
- TemplateArgs = FD->getTemplateSpecializationArgs();
+ if (FD->getTemplateSpecializationArgsAsWritten()) {
+ const ASTTemplateArgumentListInfo *ArgList =
+ FD->getTemplateSpecializationArgsAsWritten();
+ TemplateArgs.append(ArgList->getTemplateArgs(),
+ ArgList->getTemplateArgs() +
+ ArgList->NumTemplateArgs);
+ } else {
+ const TemplateArgumentList *ArgList =
+ FD->getTemplateSpecializationArgs();
+ TemplateArgumentListInfo LI;
+ for (unsigned i = 0, e = ArgList->size(); i != e; ++i)
+ TemplateArgs.push_back(TemplateArgumentLoc(ArgList->get(i),
+ FD->getTypeSourceInfo()));
+ }
return TD;
}
}
@@ -342,7 +370,21 @@
// Check if we have a class template.
if (const ClassTemplateSpecializationDecl *Spec =
dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
- TemplateArgs = &Spec->getTemplateArgs();
+ TypeSourceInfo *TSI = Spec->getTypeAsWritten();
+ if (TSI) {
+ TemplateSpecializationTypeLoc &TSTL =
+ cast<TemplateSpecializationTypeLoc>(TSI->getTypeLoc());
+ TemplateArgumentListInfo LI(TSTL.getLAngleLoc(), TSTL.getRAngleLoc());
+ for (unsigned i = 0, e = TSTL.getNumArgs(); i != e; ++i)
+ TemplateArgs.push_back(TSTL.getArgLoc(i));
+ } else {
+ TemplateArgumentListInfo LI;
+ const TemplateArgumentList &ArgList =
+ Spec->getTemplateArgs();
+ for (unsigned i = 0, e = ArgList.size(); i != e; ++i)
+ TemplateArgs.push_back(TemplateArgumentLoc(ArgList[i],
+ TemplateArgumentLocInfo()));
+ }
return Spec->getSpecializedTemplate();
}
@@ -356,11 +398,10 @@
// ::= <ctor-dtor-name>
// ::= <source-name>
// ::= <template-name>
- const TemplateArgumentList *TemplateArgs;
+ SmallVector<TemplateArgumentLoc, 2> TemplateArgs;
// Check if we have a template.
if (const TemplateDecl *TD = isTemplate(ND, TemplateArgs)) {
- mangleTemplateInstantiationName(TD, TemplateArgs->data(), TemplateArgs->size(),
- ND->getLocation());
+ mangleTemplateInstantiationName(TD, TemplateArgs);
return;
}
@@ -418,12 +459,17 @@
break;
case DeclarationName::CXXOperatorName:
- mangleOperatorName(Name.getCXXOverloadedOperator());
+ mangleOperatorName(Name.getCXXOverloadedOperator(), ND->getLocation());
break;
- case DeclarationName::CXXLiteralOperatorName:
+ case DeclarationName::CXXLiteralOperatorName: {
// FIXME: Was this added in VS2010? Does MS even know how to mangle this?
- llvm_unreachable("Don't know how to mangle literal operators yet!");
+ DiagnosticsEngine Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this literal operator yet");
+ Diags.Report(ND->getLocation(), DiagID);
+ break;
+ }
case DeclarationName::CXXUsingDirective:
llvm_unreachable("Can't mangle a using directive name!");
@@ -433,7 +479,6 @@
void MicrosoftCXXNameMangler::manglePostfix(const DeclContext *DC,
bool NoFunction) {
// <postfix> ::= <unqualified-name> [<postfix>]
- // ::= <template-param>
// ::= <substitution> [<postfix>]
if (!DC) return;
@@ -454,13 +499,16 @@
return;
else if (const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(DC))
mangleObjCMethodName(Method);
+ else if (const FunctionDecl *Func = dyn_cast<FunctionDecl>(DC))
+ mangleLocalName(Func);
else {
mangleUnqualifiedName(cast<NamedDecl>(DC));
manglePostfix(DC->getParent(), NoFunction);
}
}
-void MicrosoftCXXNameMangler::mangleOperatorName(OverloadedOperatorKind OO) {
+void MicrosoftCXXNameMangler::mangleOperatorName(OverloadedOperatorKind OO,
+ SourceLocation Loc) {
switch (OO) {
// ?0 # constructor
// ?1 # destructor
@@ -577,8 +625,13 @@
// <operator-name> ::= ?_V # delete[]
case OO_Array_Delete: Out << "?_V"; break;
- case OO_Conditional:
- llvm_unreachable("Don't know how to mangle ?:");
+ case OO_Conditional: {
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this conditional operator yet");
+ Diags.Report(Loc, DiagID);
+ break;
+ }
case OO_None:
case NUM_OVERLOADED_OPERATORS:
@@ -591,19 +644,56 @@
Out << II->getName() << '@';
}
-void MicrosoftCXXNameMangler::mangleTemplateInstantiationName(const TemplateDecl *TD,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs,
- SourceLocation InstantiationLoc) {
+void MicrosoftCXXNameMangler::mangleObjCMethodName(const ObjCMethodDecl *MD) {
+ Context.mangleObjCMethodName(MD, Out);
+}
+
+// Find out how many function decls live above this one and return an integer
+// suitable for use as the number in a numbered anonymous scope.
+// TODO: Memoize.
+static unsigned getLocalNestingLevel(const FunctionDecl *FD) {
+ const DeclContext *DC = FD->getParent();
+ int level = 1;
+
+ while (DC && !DC->isTranslationUnit()) {
+ if (isa<FunctionDecl>(DC) || isa<ObjCMethodDecl>(DC)) level++;
+ DC = DC->getParent();
+ }
+
+ return 2*level;
+}
+
+void MicrosoftCXXNameMangler::mangleLocalName(const FunctionDecl *FD) {
+ // <nested-name> ::= <numbered-anonymous-scope> ? <mangled-name>
+ // <numbered-anonymous-scope> ::= ? <number>
+ // Even though the name is rendered in reverse order (e.g.
+ // A::B::C is rendered as C at B@A), VC numbers the scopes from outermost to
+ // innermost. So a method bar in class C local to function foo gets mangled
+ // as something like:
+ // ?bar at C@?1??foo@@YAXXZ at QAEXXZ
+ // This is more apparent when you have a type nested inside a method of a
+ // type nested inside a function. A method baz in class D local to method
+ // bar of class C local to function foo gets mangled as:
+ // ?baz at D@?3??bar at C@?1??foo@@YAXXZ at QAEXXZ@QAEXXZ
+ // This scheme is general enough to support GCC-style nested
+ // functions. You could have a method baz of class C inside a function bar
+ // inside a function foo, like so:
+ // ?baz at C@?3??bar@?1??foo@@YAXXZ at YAXXZ@QAEXXZ
+ int NestLevel = getLocalNestingLevel(FD);
+ Out << '?';
+ mangleNumber(NestLevel);
+ Out << '?';
+ mangle(FD, "?");
+}
+
+void MicrosoftCXXNameMangler::mangleTemplateInstantiationName(
+ const TemplateDecl *TD,
+ const SmallVectorImpl<TemplateArgumentLoc> &TemplateArgs) {
// <template-name> ::= <unscoped-template-name> <template-args>
// ::= <substitution>
// Always start with the unqualified name.
mangleUnscopedTemplateName(TD);
- mangleTemplateArgs(TemplateArgs, NumTemplateArgs, InstantiationLoc);
-}
-
-void MicrosoftCXXNameMangler::mangleObjCMethodName(const ObjCMethodDecl *MD) {
- Context.mangleObjCMethodName(MD, Out);
+ mangleTemplateArgs(TemplateArgs);
}
void
@@ -614,7 +704,8 @@
}
void
-MicrosoftCXXNameMangler::mangleIntegerLiteral(QualType T, const llvm::APSInt &Value) {
+MicrosoftCXXNameMangler::mangleIntegerLiteral(QualType T,
+ const llvm::APSInt &Value) {
// <integer-literal> ::= $0 <number>
Out << "$0";
// Make sure booleans are encoded as 0/1.
@@ -625,29 +716,32 @@
}
void
-MicrosoftCXXNameMangler::mangleTemplateArgs(const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs,
- SourceLocation InstantiationLoc) {
+MicrosoftCXXNameMangler::mangleTemplateArgs(
+ const SmallVectorImpl<TemplateArgumentLoc> &TemplateArgs) {
// <template-args> ::= {<type> | <integer-literal>}+ @
- for (unsigned int i = 0; i < NumTemplateArgs; ++i) {
- const TemplateArgument &TA = TemplateArgs[i];
+ unsigned NumTemplateArgs = TemplateArgs.size();
+ for (unsigned i = 0; i < NumTemplateArgs; ++i) {
+ const TemplateArgumentLoc &TAL = TemplateArgs[i];
+ const TemplateArgument &TA = TAL.getArgument();
switch (TA.getKind()) {
- case TemplateArgument::Null:
- llvm_unreachable("Can't mangle null template arguments!");
+ case TemplateArgument::Null:
+ llvm_unreachable("Can't mangle null template arguments!");
case TemplateArgument::Type:
- mangleType(TA.getAsType());
+ mangleType(TA.getAsType(), TAL.getSourceRange());
break;
case TemplateArgument::Integral:
- mangleIntegerLiteral(TA.getIntegralType(), *TA.getAsIntegral());
+ mangleIntegerLiteral(TA.getIntegralType(), TA.getAsIntegral());
break;
default: {
- // Issue a diagnostic.
- DiagnosticsEngine &Diags = Context.getDiags();
- unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
- "cannot yet mangle this %select{null|type|pointer/reference|integral|template|"
- "template pack expansion|expression|parameter pack}0 template argument");
- Diags.Report(InstantiationLoc, DiagID)
- << TA.getKind();
+ // Issue a diagnostic.
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this %select{ERROR|ERROR|pointer/reference|ERROR|"
+ "template|template pack expansion|expression|parameter pack}0 "
+ "template argument yet");
+ Diags.Report(TAL.getLocation(), DiagID)
+ << TA.getKind()
+ << TAL.getSourceRange();
}
}
}
@@ -737,7 +831,7 @@
// FIXME: For now, just drop all extension qualifiers on the floor.
}
-void MicrosoftCXXNameMangler::mangleType(QualType T) {
+void MicrosoftCXXNameMangler::mangleType(QualType T, SourceRange Range) {
// Only operate on the canonical type!
T = getASTContext().getCanonicalType(T);
@@ -771,18 +865,22 @@
switch (T->getTypeClass()) {
#define ABSTRACT_TYPE(CLASS, PARENT)
#define NON_CANONICAL_TYPE(CLASS, PARENT) \
-case Type::CLASS: \
-llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \
-return;
+ case Type::CLASS: \
+ llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \
+ return;
#define TYPE(CLASS, PARENT) \
-case Type::CLASS: \
-mangleType(static_cast<const CLASS##Type*>(T.getTypePtr())); \
-break;
+ case Type::CLASS: \
+ mangleType(static_cast<const CLASS##Type*>(T.getTypePtr()), Range); \
+ break;
#include "clang/AST/TypeNodes.def"
+#undef ABSTRACT_TYPE
+#undef NON_CANONICAL_TYPE
+#undef TYPE
}
}
-void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T) {
+void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T,
+ SourceRange Range) {
// <type> ::= <builtin-type>
// <builtin-type> ::= X # void
// ::= C # signed char
@@ -844,20 +942,28 @@
case BuiltinType::Char16:
case BuiltinType::Char32:
case BuiltinType::Half:
- case BuiltinType::NullPtr:
- assert(0 && "Don't know how to mangle this type yet");
+ case BuiltinType::NullPtr: {
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this built-in %0 type yet");
+ Diags.Report(Range.getBegin(), DiagID)
+ << T->getName(Context.getASTContext().getPrintingPolicy())
+ << Range;
+ }
}
}
// <type> ::= <function-type>
-void MicrosoftCXXNameMangler::mangleType(const FunctionProtoType *T) {
+void MicrosoftCXXNameMangler::mangleType(const FunctionProtoType *T,
+ SourceRange) {
// Structors only appear in decls, so at this point we know it's not a
// structor type.
// I'll probably have mangleType(MemberPointerType) call the mangleType()
// method directly.
mangleType(T, NULL, false, false);
}
-void MicrosoftCXXNameMangler::mangleType(const FunctionNoProtoType *T) {
+void MicrosoftCXXNameMangler::mangleType(const FunctionNoProtoType *T,
+ SourceRange) {
llvm_unreachable("Can't mangle K&R function prototypes");
}
@@ -881,7 +987,10 @@
if (IsStructor)
Out << '@';
else
- mangleType(Proto->getResultType());
+ // FIXME: Get the source range for the result type. Or, better yet,
+ // implement the unimplemented stuff so we don't need accurate source
+ // location info anymore :).
+ mangleType(Proto->getResultType(), SourceRange());
// <argument-list> ::= X # void
// ::= <type>+ @
@@ -896,15 +1005,16 @@
for (FunctionDecl::param_const_iterator Parm = D->param_begin(),
ParmEnd = D->param_end(); Parm != ParmEnd; ++Parm) {
if (TypeSourceInfo *typeAsWritten = (*Parm)->getTypeSourceInfo())
- mangleType(typeAsWritten->getType());
+ mangleType(typeAsWritten->getType(),
+ typeAsWritten->getTypeLoc().getSourceRange());
else
- mangleType((*Parm)->getType());
+ mangleType((*Parm)->getType(), SourceRange());
}
} else {
for (FunctionProtoType::arg_type_iterator Arg = Proto->arg_type_begin(),
ArgEnd = Proto->arg_type_end();
Arg != ArgEnd; ++Arg)
- mangleType(*Arg);
+ mangleType(*Arg, SourceRange());
}
// <builtin-type> ::= Z # ellipsis
if (Proto->isVariadic())
@@ -1015,8 +1125,15 @@
Out << 'Z';
}
-void MicrosoftCXXNameMangler::mangleType(const UnresolvedUsingType *T) {
- llvm_unreachable("Don't know how to mangle UnresolvedUsingTypes yet!");
+void MicrosoftCXXNameMangler::mangleType(const UnresolvedUsingType *T,
+ SourceRange Range) {
+ // Probably should be mangled as a template instantiation; need to see what
+ // VC does first.
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this unresolved dependent type yet");
+ Diags.Report(Range.getBegin(), DiagID)
+ << Range;
}
// <type> ::= <union-type> | <struct-type> | <class-type> | <enum-type>
@@ -1024,10 +1141,10 @@
// <struct-type> ::= U <name>
// <class-type> ::= V <name>
// <enum-type> ::= W <size> <name>
-void MicrosoftCXXNameMangler::mangleType(const EnumType *T) {
+void MicrosoftCXXNameMangler::mangleType(const EnumType *T, SourceRange) {
mangleType(static_cast<const TagType*>(T));
}
-void MicrosoftCXXNameMangler::mangleType(const RecordType *T) {
+void MicrosoftCXXNameMangler::mangleType(const RecordType *T, SourceRange) {
mangleType(static_cast<const TagType*>(T));
}
void MicrosoftCXXNameMangler::mangleType(const TagType *T) {
@@ -1067,31 +1184,48 @@
Out << 'Q';
mangleExtraDimensions(T->getElementType());
}
-void MicrosoftCXXNameMangler::mangleType(const ConstantArrayType *T) {
+void MicrosoftCXXNameMangler::mangleType(const ConstantArrayType *T,
+ SourceRange) {
mangleType(static_cast<const ArrayType *>(T), false);
}
-void MicrosoftCXXNameMangler::mangleType(const VariableArrayType *T) {
+void MicrosoftCXXNameMangler::mangleType(const VariableArrayType *T,
+ SourceRange) {
mangleType(static_cast<const ArrayType *>(T), false);
}
-void MicrosoftCXXNameMangler::mangleType(const DependentSizedArrayType *T) {
+void MicrosoftCXXNameMangler::mangleType(const DependentSizedArrayType *T,
+ SourceRange) {
mangleType(static_cast<const ArrayType *>(T), false);
}
-void MicrosoftCXXNameMangler::mangleType(const IncompleteArrayType *T) {
+void MicrosoftCXXNameMangler::mangleType(const IncompleteArrayType *T,
+ SourceRange) {
mangleType(static_cast<const ArrayType *>(T), false);
}
void MicrosoftCXXNameMangler::mangleExtraDimensions(QualType ElementTy) {
SmallVector<llvm::APInt, 3> Dimensions;
for (;;) {
- if (ElementTy->isConstantArrayType()) {
- const ConstantArrayType *CAT =
- static_cast<const ConstantArrayType *>(ElementTy.getTypePtr());
+ if (const ConstantArrayType *CAT =
+ getASTContext().getAsConstantArrayType(ElementTy)) {
Dimensions.push_back(CAT->getSize());
ElementTy = CAT->getElementType();
} else if (ElementTy->isVariableArrayType()) {
- llvm_unreachable("Don't know how to mangle VLAs!");
+ const VariableArrayType *VAT =
+ getASTContext().getAsVariableArrayType(ElementTy);
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this variable-length array yet");
+ Diags.Report(VAT->getSizeExpr()->getExprLoc(), DiagID)
+ << VAT->getBracketsRange();
+ return;
} else if (ElementTy->isDependentSizedArrayType()) {
// The dependent expression has to be folded into a constant (TODO).
- llvm_unreachable("Don't know how to mangle dependent-sized arrays!");
+ const DependentSizedArrayType *DSAT =
+ getASTContext().getAsDependentSizedArrayType(ElementTy);
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this dependent-length array yet");
+ Diags.Report(DSAT->getSizeExpr()->getExprLoc(), DiagID)
+ << DSAT->getBracketsRange();
+ return;
} else if (ElementTy->isIncompleteArrayType()) continue;
else break;
}
@@ -1105,151 +1239,243 @@
mangleNumber(Dimensions[Dim].getLimitedValue());
}
}
- mangleType(ElementTy.getLocalUnqualifiedType());
+ mangleType(ElementTy.getLocalUnqualifiedType(), SourceRange());
}
// <type> ::= <pointer-to-member-type>
// <pointer-to-member-type> ::= <pointer-cvr-qualifiers> <cvr-qualifiers>
// <class name> <type>
-void MicrosoftCXXNameMangler::mangleType(const MemberPointerType *T) {
+void MicrosoftCXXNameMangler::mangleType(const MemberPointerType *T,
+ SourceRange Range) {
QualType PointeeType = T->getPointeeType();
- if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(PointeeType)) {
+ if (const FunctionProtoType *FPT = PointeeType->getAs<FunctionProtoType>()) {
Out << '8';
- mangleName(cast<RecordType>(T->getClass())->getDecl());
+ mangleName(T->getClass()->castAs<RecordType>()->getDecl());
mangleType(FPT, NULL, false, true);
} else {
mangleQualifiers(PointeeType.getQualifiers(), true);
- mangleName(cast<RecordType>(T->getClass())->getDecl());
- mangleType(PointeeType.getLocalUnqualifiedType());
+ mangleName(T->getClass()->castAs<RecordType>()->getDecl());
+ mangleType(PointeeType.getLocalUnqualifiedType(), Range);
}
}
-void MicrosoftCXXNameMangler::mangleType(const TemplateTypeParmType *T) {
- llvm_unreachable("Don't know how to mangle TemplateTypeParmTypes yet!");
+void MicrosoftCXXNameMangler::mangleType(const TemplateTypeParmType *T,
+ SourceRange Range) {
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this template type parameter type yet");
+ Diags.Report(Range.getBegin(), DiagID)
+ << Range;
}
void MicrosoftCXXNameMangler::mangleType(
- const SubstTemplateTypeParmPackType *T) {
- llvm_unreachable(
- "Don't know how to mangle SubstTemplateTypeParmPackTypes yet!");
+ const SubstTemplateTypeParmPackType *T,
+ SourceRange Range) {
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this substituted parameter pack yet");
+ Diags.Report(Range.getBegin(), DiagID)
+ << Range;
}
// <type> ::= <pointer-type>
// <pointer-type> ::= <pointer-cvr-qualifiers> <cvr-qualifiers> <type>
-void MicrosoftCXXNameMangler::mangleType(const PointerType *T) {
+void MicrosoftCXXNameMangler::mangleType(const PointerType *T,
+ SourceRange Range) {
QualType PointeeTy = T->getPointeeType();
if (PointeeTy->isArrayType()) {
// Pointers to arrays are mangled like arrays.
- mangleExtraDimensions(T->getPointeeType());
- } else if (PointeeTy->isFunctionType()) {
+ mangleExtraDimensions(PointeeTy);
+ } else if (const FunctionType *FT = PointeeTy->getAs<FunctionType>()) {
// Function pointers are special.
Out << '6';
- mangleType(static_cast<const FunctionType *>(PointeeTy.getTypePtr()),
- NULL, false, false);
+ mangleType(FT, NULL, false, false);
} else {
if (!PointeeTy.hasQualifiers())
// Lack of qualifiers is mangled as 'A'.
Out << 'A';
- mangleType(PointeeTy);
+ mangleType(PointeeTy, Range);
}
}
-void MicrosoftCXXNameMangler::mangleType(const ObjCObjectPointerType *T) {
+void MicrosoftCXXNameMangler::mangleType(const ObjCObjectPointerType *T,
+ SourceRange Range) {
// Object pointers never have qualifiers.
Out << 'A';
- mangleType(T->getPointeeType());
+ mangleType(T->getPointeeType(), Range);
}
// <type> ::= <reference-type>
// <reference-type> ::= A <cvr-qualifiers> <type>
-void MicrosoftCXXNameMangler::mangleType(const LValueReferenceType *T) {
+void MicrosoftCXXNameMangler::mangleType(const LValueReferenceType *T,
+ SourceRange Range) {
Out << 'A';
QualType PointeeTy = T->getPointeeType();
if (!PointeeTy.hasQualifiers())
// Lack of qualifiers is mangled as 'A'.
Out << 'A';
- mangleType(PointeeTy);
+ mangleType(PointeeTy, Range);
}
-void MicrosoftCXXNameMangler::mangleType(const RValueReferenceType *T) {
- llvm_unreachable("Don't know how to mangle RValueReferenceTypes yet!");
+void MicrosoftCXXNameMangler::mangleType(const RValueReferenceType *T,
+ SourceRange Range) {
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this r-value reference type yet");
+ Diags.Report(Range.getBegin(), DiagID)
+ << Range;
+}
+
+void MicrosoftCXXNameMangler::mangleType(const ComplexType *T,
+ SourceRange Range) {
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this complex number type yet");
+ Diags.Report(Range.getBegin(), DiagID)
+ << Range;
+}
+
+void MicrosoftCXXNameMangler::mangleType(const VectorType *T,
+ SourceRange Range) {
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this vector type yet");
+ Diags.Report(Range.getBegin(), DiagID)
+ << Range;
+}
+void MicrosoftCXXNameMangler::mangleType(const ExtVectorType *T,
+ SourceRange Range) {
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this extended vector type yet");
+ Diags.Report(Range.getBegin(), DiagID)
+ << Range;
+}
+void MicrosoftCXXNameMangler::mangleType(const DependentSizedExtVectorType *T,
+ SourceRange Range) {
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this dependent-sized extended vector type yet");
+ Diags.Report(Range.getBegin(), DiagID)
+ << Range;
}
-void MicrosoftCXXNameMangler::mangleType(const ComplexType *T) {
- llvm_unreachable("Don't know how to mangle ComplexTypes yet!");
-}
-
-void MicrosoftCXXNameMangler::mangleType(const VectorType *T) {
- llvm_unreachable("Don't know how to mangle VectorTypes yet!");
-}
-void MicrosoftCXXNameMangler::mangleType(const ExtVectorType *T) {
- llvm_unreachable("Don't know how to mangle ExtVectorTypes yet!");
-}
-void MicrosoftCXXNameMangler::mangleType(const DependentSizedExtVectorType *T) {
- llvm_unreachable(
- "Don't know how to mangle DependentSizedExtVectorTypes yet!");
-}
-
-void MicrosoftCXXNameMangler::mangleType(const ObjCInterfaceType *T) {
+void MicrosoftCXXNameMangler::mangleType(const ObjCInterfaceType *T,
+ SourceRange) {
// ObjC interfaces have structs underlying them.
Out << 'U';
mangleName(T->getDecl());
}
-void MicrosoftCXXNameMangler::mangleType(const ObjCObjectType *T) {
+void MicrosoftCXXNameMangler::mangleType(const ObjCObjectType *T,
+ SourceRange Range) {
// We don't allow overloading by different protocol qualification,
// so mangling them isn't necessary.
- mangleType(T->getBaseType());
+ mangleType(T->getBaseType(), Range);
}
-void MicrosoftCXXNameMangler::mangleType(const BlockPointerType *T) {
+void MicrosoftCXXNameMangler::mangleType(const BlockPointerType *T,
+ SourceRange Range) {
Out << "_E";
- mangleType(T->getPointeeType());
+ mangleType(T->getPointeeType(), Range);
}
-void MicrosoftCXXNameMangler::mangleType(const InjectedClassNameType *T) {
- llvm_unreachable("Don't know how to mangle InjectedClassNameTypes yet!");
-}
-
-void MicrosoftCXXNameMangler::mangleType(const TemplateSpecializationType *T) {
- llvm_unreachable("Don't know how to mangle TemplateSpecializationTypes yet!");
-}
-
-void MicrosoftCXXNameMangler::mangleType(const DependentNameType *T) {
- llvm_unreachable("Don't know how to mangle DependentNameTypes yet!");
+void MicrosoftCXXNameMangler::mangleType(const InjectedClassNameType *T,
+ SourceRange Range) {
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this injected class name type yet");
+ Diags.Report(Range.getBegin(), DiagID)
+ << Range;
+}
+
+void MicrosoftCXXNameMangler::mangleType(const TemplateSpecializationType *T,
+ SourceRange Range) {
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this template specialization type yet");
+ Diags.Report(Range.getBegin(), DiagID)
+ << Range;
+}
+
+void MicrosoftCXXNameMangler::mangleType(const DependentNameType *T,
+ SourceRange Range) {
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this dependent name type yet");
+ Diags.Report(Range.getBegin(), DiagID)
+ << Range;
}
void MicrosoftCXXNameMangler::mangleType(
- const DependentTemplateSpecializationType *T) {
- llvm_unreachable(
- "Don't know how to mangle DependentTemplateSpecializationTypes yet!");
-}
-
-void MicrosoftCXXNameMangler::mangleType(const PackExpansionType *T) {
- llvm_unreachable("Don't know how to mangle PackExpansionTypes yet!");
-}
-
-void MicrosoftCXXNameMangler::mangleType(const TypeOfType *T) {
- llvm_unreachable("Don't know how to mangle TypeOfTypes yet!");
-}
-
-void MicrosoftCXXNameMangler::mangleType(const TypeOfExprType *T) {
- llvm_unreachable("Don't know how to mangle TypeOfExprTypes yet!");
-}
-
-void MicrosoftCXXNameMangler::mangleType(const DecltypeType *T) {
- llvm_unreachable("Don't know how to mangle DecltypeTypes yet!");
-}
-
-void MicrosoftCXXNameMangler::mangleType(const UnaryTransformType *T) {
- llvm_unreachable("Don't know how to mangle UnaryTransformationTypes yet!");
-}
-
-void MicrosoftCXXNameMangler::mangleType(const AutoType *T) {
- llvm_unreachable("Don't know how to mangle AutoTypes yet!");
-}
-
-void MicrosoftCXXNameMangler::mangleType(const AtomicType *T) {
- llvm_unreachable("Don't know how to mangle AtomicTypes yet!");
+ const DependentTemplateSpecializationType *T,
+ SourceRange Range) {
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this dependent template specialization type yet");
+ Diags.Report(Range.getBegin(), DiagID)
+ << Range;
+}
+
+void MicrosoftCXXNameMangler::mangleType(const PackExpansionType *T,
+ SourceRange Range) {
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this pack expansion yet");
+ Diags.Report(Range.getBegin(), DiagID)
+ << Range;
+}
+
+void MicrosoftCXXNameMangler::mangleType(const TypeOfType *T,
+ SourceRange Range) {
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this typeof(type) yet");
+ Diags.Report(Range.getBegin(), DiagID)
+ << Range;
+}
+
+void MicrosoftCXXNameMangler::mangleType(const TypeOfExprType *T,
+ SourceRange Range) {
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this typeof(expression) yet");
+ Diags.Report(Range.getBegin(), DiagID)
+ << Range;
+}
+
+void MicrosoftCXXNameMangler::mangleType(const DecltypeType *T,
+ SourceRange Range) {
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this decltype() yet");
+ Diags.Report(Range.getBegin(), DiagID)
+ << Range;
+}
+
+void MicrosoftCXXNameMangler::mangleType(const UnaryTransformType *T,
+ SourceRange Range) {
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this unary transform type yet");
+ Diags.Report(Range.getBegin(), DiagID)
+ << Range;
+}
+
+void MicrosoftCXXNameMangler::mangleType(const AutoType *T, SourceRange Range) {
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this 'auto' type yet");
+ Diags.Report(Range.getBegin(), DiagID)
+ << Range;
+}
+
+void MicrosoftCXXNameMangler::mangleType(const AtomicType *T,
+ SourceRange Range) {
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this C11 atomic type yet");
+ Diags.Report(Range.getBegin(), DiagID)
+ << Range;
}
void MicrosoftMangleContext::mangleName(const NamedDecl *D,
@@ -1269,17 +1495,35 @@
void MicrosoftMangleContext::mangleThunk(const CXXMethodDecl *MD,
const ThunkInfo &Thunk,
raw_ostream &) {
- llvm_unreachable("Can't yet mangle thunks!");
+ unsigned DiagID = getDiags().getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle thunk for this method yet");
+ getDiags().Report(MD->getLocation(), DiagID);
}
void MicrosoftMangleContext::mangleCXXDtorThunk(const CXXDestructorDecl *DD,
CXXDtorType Type,
const ThisAdjustment &,
raw_ostream &) {
- llvm_unreachable("Can't yet mangle destructor thunks!");
+ unsigned DiagID = getDiags().getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle thunk for this destructor yet");
+ getDiags().Report(DD->getLocation(), DiagID);
}
void MicrosoftMangleContext::mangleCXXVTable(const CXXRecordDecl *RD,
- raw_ostream &) {
- llvm_unreachable("Can't yet mangle virtual tables!");
+ raw_ostream &Out) {
+ // <mangled-name> ::= ? <operator-name> <class-name> <storage-class>
+ // <cvr-qualifiers> [<name>] @
+ // <operator-name> ::= _7 # vftable
+ // ::= _8 # vbtable
+ // NOTE: <cvr-qualifiers> here is always 'B' (const). <storage-class>
+ // is always '6' for vftables and '7' for vbtables. (The difference is
+ // beyond me.)
+ // TODO: vbtables.
+ MicrosoftCXXNameMangler Mangler(*this, Out);
+ Mangler.getStream() << "\01??_7";
+ Mangler.mangleName(RD);
+ Mangler.getStream() << "6B";
+ // TODO: If the class has more than one vtable, mangle in the class it came
+ // from.
+ Mangler.getStream() << '@';
}
void MicrosoftMangleContext::mangleCXXVTT(const CXXRecordDecl *RD,
raw_ostream &) {
@@ -1293,11 +1537,19 @@
}
void MicrosoftMangleContext::mangleCXXRTTI(QualType T,
raw_ostream &) {
- llvm_unreachable("Can't yet mangle RTTI!");
+ // FIXME: Give a location...
+ unsigned DiagID = getDiags().getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle RTTI descriptors for type %0 yet");
+ getDiags().Report(DiagID)
+ << T.getBaseTypeIdentifier();
}
void MicrosoftMangleContext::mangleCXXRTTIName(QualType T,
raw_ostream &) {
- llvm_unreachable("Can't yet mangle RTTI names!");
+ // FIXME: Give a location...
+ unsigned DiagID = getDiags().getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle the name of type %0 into RTTI descriptors yet");
+ getDiags().Report(DiagID)
+ << T.getBaseTypeIdentifier();
}
void MicrosoftMangleContext::mangleCXXCtor(const CXXConstructorDecl *D,
CXXCtorType Type,
@@ -1311,9 +1563,11 @@
MicrosoftCXXNameMangler mangler(*this, Out);
mangler.mangle(D);
}
-void MicrosoftMangleContext::mangleReferenceTemporary(const clang::VarDecl *,
+void MicrosoftMangleContext::mangleReferenceTemporary(const clang::VarDecl *VD,
raw_ostream &) {
- llvm_unreachable("Can't yet mangle reference temporaries!");
+ unsigned DiagID = getDiags().getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this reference temporary yet");
+ getDiags().Report(VD->getLocation(), DiagID);
}
MangleContext *clang::createMicrosoftMangleContext(ASTContext &Context,
Modified: cfe/branches/tooling/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/RecordLayoutBuilder.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/branches/tooling/lib/AST/RecordLayoutBuilder.cpp Fri Jun 15 06:08:27 2012
@@ -161,10 +161,9 @@
// Check the fields.
for (CXXRecordDecl::field_iterator I = Class->field_begin(),
E = Class->field_end(); I != E; ++I) {
- const FieldDecl &FD = *I;
const RecordType *RT =
- Context.getBaseElementType(FD.getType())->getAs<RecordType>();
+ Context.getBaseElementType(I->getType())->getAs<RecordType>();
// We only care about record types.
if (!RT)
@@ -261,12 +260,11 @@
unsigned FieldNo = 0;
for (CXXRecordDecl::field_iterator I = Info->Class->field_begin(),
E = Info->Class->field_end(); I != E; ++I, ++FieldNo) {
- const FieldDecl *FD = &*I;
- if (FD->isBitField())
+ if (I->isBitField())
continue;
CharUnits FieldOffset = Offset + getFieldOffset(Layout, FieldNo);
- if (!CanPlaceFieldSubobjectAtOffset(FD, FieldOffset))
+ if (!CanPlaceFieldSubobjectAtOffset(*I, FieldOffset))
return false;
}
@@ -310,12 +308,11 @@
unsigned FieldNo = 0;
for (CXXRecordDecl::field_iterator I = Info->Class->field_begin(),
E = Info->Class->field_end(); I != E; ++I, ++FieldNo) {
- const FieldDecl *FD = &*I;
- if (FD->isBitField())
+ if (I->isBitField())
continue;
CharUnits FieldOffset = Offset + getFieldOffset(Layout, FieldNo);
- UpdateEmptyFieldSubobjects(FD, FieldOffset);
+ UpdateEmptyFieldSubobjects(*I, FieldOffset);
}
}
@@ -380,13 +377,12 @@
unsigned FieldNo = 0;
for (CXXRecordDecl::field_iterator I = RD->field_begin(), E = RD->field_end();
I != E; ++I, ++FieldNo) {
- const FieldDecl *FD = &*I;
- if (FD->isBitField())
+ if (I->isBitField())
continue;
CharUnits FieldOffset = Offset + getFieldOffset(Layout, FieldNo);
- if (!CanPlaceFieldSubobjectAtOffset(FD, FieldOffset))
+ if (!CanPlaceFieldSubobjectAtOffset(*I, FieldOffset))
return false;
}
@@ -491,13 +487,12 @@
unsigned FieldNo = 0;
for (CXXRecordDecl::field_iterator I = RD->field_begin(), E = RD->field_end();
I != E; ++I, ++FieldNo) {
- const FieldDecl *FD = &*I;
- if (FD->isBitField())
+ if (I->isBitField())
continue;
CharUnits FieldOffset = Offset + getFieldOffset(Layout, FieldNo);
- UpdateEmptyFieldSubobjects(FD, FieldOffset);
+ UpdateEmptyFieldSubobjects(*I, FieldOffset);
}
}
@@ -1730,7 +1725,7 @@
for (RecordDecl::field_iterator Field = D->field_begin(),
FieldEnd = D->field_end(); Field != FieldEnd; ++Field) {
if (IsMsStruct) {
- FieldDecl *FD = &*Field;
+ FieldDecl *FD = *Field;
if (Context.ZeroBitfieldFollowsBitfield(FD, LastFD))
ZeroLengthBitfield = FD;
// Zero-length bitfields following non-bitfield members are
@@ -1825,11 +1820,10 @@
}
else if (!Context.getTargetInfo().useBitFieldTypeAlignment() &&
Context.getTargetInfo().useZeroLengthBitfieldAlignment()) {
- FieldDecl *FD = &*Field;
- if (FD->isBitField() && FD->getBitWidthValue(Context) == 0)
- ZeroLengthBitfield = FD;
+ if (Field->isBitField() && Field->getBitWidthValue(Context) == 0)
+ ZeroLengthBitfield = *Field;
}
- LayoutField(&*Field);
+ LayoutField(*Field);
}
if (IsMsStruct && RemainingInAlignment &&
LastFD && LastFD->isBitField() && LastFD->getBitWidthValue(Context)) {
@@ -2337,7 +2331,7 @@
for (CXXRecordDecl::method_iterator I = RD->method_begin(),
E = RD->method_end(); I != E; ++I) {
- const CXXMethodDecl *MD = &*I;
+ const CXXMethodDecl *MD = *I;
if (!MD->isVirtual())
continue;
@@ -2607,7 +2601,7 @@
uint64_t FieldNo = 0;
for (CXXRecordDecl::field_iterator I = RD->field_begin(),
E = RD->field_end(); I != E; ++I, ++FieldNo) {
- const FieldDecl &Field = *I;
+ const FieldDecl &Field = **I;
CharUnits FieldOffset = Offset +
C.toCharUnitsFromBits(Layout.getFieldOffset(FieldNo));
Modified: cfe/branches/tooling/lib/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/Stmt.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/Stmt.cpp (original)
+++ cfe/branches/tooling/lib/AST/Stmt.cpp Fri Jun 15 06:08:27 2012
@@ -550,6 +550,12 @@
std::copy(clobbers, clobbers + NumClobbers, Clobbers);
}
+MSAsmStmt::MSAsmStmt(ASTContext &C, SourceLocation asmloc, std::string &asmstr,
+ SourceLocation endloc)
+ : Stmt(MSAsmStmtClass), AsmLoc(asmloc), EndLoc(endloc), AsmStr(asmstr),
+ IsSimple(true), IsVolatile(true) {
+}
+
ObjCForCollectionStmt::ObjCForCollectionStmt(Stmt *Elem, Expr *Collect,
Stmt *Body, SourceLocation FCL,
SourceLocation RPL)
Modified: cfe/branches/tooling/lib/AST/StmtDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/StmtDumper.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/StmtDumper.cpp (original)
+++ cfe/branches/tooling/lib/AST/StmtDumper.cpp Fri Jun 15 06:08:27 2012
@@ -446,18 +446,8 @@
void StmtDumper::VisitStringLiteral(StringLiteral *Str) {
DumpExpr(Str);
- // FIXME: this doesn't print wstrings right.
OS << " ";
- switch (Str->getKind()) {
- case StringLiteral::Ascii: break; // No prefix
- case StringLiteral::Wide: OS << 'L'; break;
- case StringLiteral::UTF8: OS << "u8"; break;
- case StringLiteral::UTF16: OS << 'u'; break;
- case StringLiteral::UTF32: OS << 'U'; break;
- }
- OS << '"';
- OS.write_escaped(Str->getString());
- OS << '"';
+ Str->outputString(OS);
}
void StmtDumper::VisitUnaryOperator(UnaryOperator *Node) {
Modified: cfe/branches/tooling/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/StmtPrinter.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/StmtPrinter.cpp (original)
+++ cfe/branches/tooling/lib/AST/StmtPrinter.cpp Fri Jun 15 06:08:27 2012
@@ -429,6 +429,11 @@
OS << ");\n";
}
+void StmtPrinter::VisitMSAsmStmt(MSAsmStmt *Node) {
+ // FIXME: Implement MS style inline asm statement printer.
+ Indent() << "asm ()";
+}
+
void StmtPrinter::VisitObjCAtTryStmt(ObjCAtTryStmt *Node) {
Indent() << "@try";
if (CompoundStmt *TS = dyn_cast<CompoundStmt>(Node->getTryBody())) {
@@ -734,93 +739,7 @@
}
void StmtPrinter::VisitStringLiteral(StringLiteral *Str) {
- switch (Str->getKind()) {
- case StringLiteral::Ascii: break; // no prefix.
- case StringLiteral::Wide: OS << 'L'; break;
- case StringLiteral::UTF8: OS << "u8"; break;
- case StringLiteral::UTF16: OS << 'u'; break;
- case StringLiteral::UTF32: OS << 'U'; break;
- }
- OS << '"';
- static const char Hex[] = "0123456789ABCDEF";
-
- unsigned LastSlashX = Str->getLength();
- for (unsigned I = 0, N = Str->getLength(); I != N; ++I) {
- switch (uint32_t Char = Str->getCodeUnit(I)) {
- default:
- // FIXME: Convert UTF-8 back to codepoints before rendering.
-
- // Convert UTF-16 surrogate pairs back to codepoints before rendering.
- // Leave invalid surrogates alone; we'll use \x for those.
- if (Str->getKind() == StringLiteral::UTF16 && I != N - 1 &&
- Char >= 0xd800 && Char <= 0xdbff) {
- uint32_t Trail = Str->getCodeUnit(I + 1);
- if (Trail >= 0xdc00 && Trail <= 0xdfff) {
- Char = 0x10000 + ((Char - 0xd800) << 10) + (Trail - 0xdc00);
- ++I;
- }
- }
-
- if (Char > 0xff) {
- // If this is a wide string, output characters over 0xff using \x
- // escapes. Otherwise, this is a UTF-16 or UTF-32 string, and Char is a
- // codepoint: use \x escapes for invalid codepoints.
- if (Str->getKind() == StringLiteral::Wide ||
- (Char >= 0xd800 && Char <= 0xdfff) || Char >= 0x110000) {
- // FIXME: Is this the best way to print wchar_t?
- OS << "\\x";
- int Shift = 28;
- while ((Char >> Shift) == 0)
- Shift -= 4;
- for (/**/; Shift >= 0; Shift -= 4)
- OS << Hex[(Char >> Shift) & 15];
- LastSlashX = I;
- break;
- }
-
- if (Char > 0xffff)
- OS << "\\U00"
- << Hex[(Char >> 20) & 15]
- << Hex[(Char >> 16) & 15];
- else
- OS << "\\u";
- OS << Hex[(Char >> 12) & 15]
- << Hex[(Char >> 8) & 15]
- << Hex[(Char >> 4) & 15]
- << Hex[(Char >> 0) & 15];
- break;
- }
-
- // If we used \x... for the previous character, and this character is a
- // hexadecimal digit, prevent it being slurped as part of the \x.
- if (LastSlashX + 1 == I) {
- switch (Char) {
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- OS << "\"\"";
- }
- }
-
- if (Char <= 0xff && isprint(Char))
- OS << (char)Char;
- else // Output anything hard as an octal escape.
- OS << '\\'
- << (char)('0' + ((Char >> 6) & 7))
- << (char)('0' + ((Char >> 3) & 7))
- << (char)('0' + ((Char >> 0) & 7));
- break;
- // Handle some common non-printable cases to make dumps prettier.
- case '\\': OS << "\\\\"; break;
- case '"': OS << "\\\""; break;
- case '\n': OS << "\\n"; break;
- case '\t': OS << "\\t"; break;
- case '\a': OS << "\\a"; break;
- case '\b': OS << "\\b"; break;
- }
- }
- OS << '"';
+ Str->outputString(OS);
}
void StmtPrinter::VisitParenExpr(ParenExpr *Node) {
OS << "(";
@@ -1275,7 +1194,7 @@
const TemplateArgument &Pack = Args->get(0);
for (TemplateArgument::pack_iterator I = Pack.pack_begin(),
E = Pack.pack_end(); I != E; ++I) {
- char C = (char)I->getAsIntegral()->getZExtValue();
+ char C = (char)I->getAsIntegral().getZExtValue();
OS << C;
}
break;
Modified: cfe/branches/tooling/lib/AST/StmtProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/StmtProfile.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/StmtProfile.cpp (original)
+++ cfe/branches/tooling/lib/AST/StmtProfile.cpp Fri Jun 15 06:08:27 2012
@@ -178,6 +178,11 @@
VisitStringLiteral(S->getClobber(I));
}
+void StmtProfiler::VisitMSAsmStmt(const MSAsmStmt *S) {
+ // FIXME: Implement MS style inline asm statement profiler.
+ VisitStmt(S);
+}
+
void StmtProfiler::VisitCXXCatchStmt(const CXXCatchStmt *S) {
VisitStmt(S);
VisitType(S->getCaughtType());
@@ -1161,7 +1166,7 @@
break;
case TemplateArgument::Integral:
- Arg.getAsIntegral()->Profile(ID);
+ Arg.getAsIntegral().Profile(ID);
VisitType(Arg.getIntegralType());
break;
Modified: cfe/branches/tooling/lib/AST/TemplateBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/TemplateBase.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/TemplateBase.cpp (original)
+++ cfe/branches/tooling/lib/AST/TemplateBase.cpp Fri Jun 15 06:08:27 2012
@@ -36,17 +36,17 @@
static void printIntegral(const TemplateArgument &TemplArg,
raw_ostream &Out) {
const ::clang::Type *T = TemplArg.getIntegralType().getTypePtr();
- const llvm::APSInt *Val = TemplArg.getAsIntegral();
+ const llvm::APSInt &Val = TemplArg.getAsIntegral();
if (T->isBooleanType()) {
- Out << (Val->getBoolValue() ? "true" : "false");
+ Out << (Val.getBoolValue() ? "true" : "false");
} else if (T->isCharType()) {
- const char Ch = Val->getZExtValue();
+ const char Ch = Val.getZExtValue();
Out << ((Ch == '\'') ? "'\\" : "'");
Out.write_escaped(StringRef(&Ch, 1), /*UseHexEscapes=*/ true);
Out << "'";
} else {
- Out << Val->toString(10);
+ Out << Val;
}
}
@@ -54,6 +54,25 @@
// TemplateArgument Implementation
//===----------------------------------------------------------------------===//
+TemplateArgument::TemplateArgument(ASTContext &Ctx, const llvm::APSInt &Value,
+ QualType Type)
+ : Kind(Integral) {
+ // Copy the APSInt value into our decomposed form.
+ Integer.BitWidth = Value.getBitWidth();
+ Integer.IsUnsigned = Value.isUnsigned();
+ // If the value is large, we have to get additional memory from the ASTContext
+ unsigned NumWords = Value.getNumWords();
+ if (NumWords > 1) {
+ void *Mem = Ctx.Allocate(NumWords * sizeof(uint64_t));
+ std::memcpy(Mem, Value.getRawData(), NumWords * sizeof(uint64_t));
+ Integer.pVal = static_cast<uint64_t *>(Mem);
+ } else {
+ Integer.VAL = Value.getZExtValue();
+ }
+
+ Integer.Type = Type.getAsOpaquePtr();
+}
+
TemplateArgument TemplateArgument::CreatePackCopy(ASTContext &Context,
const TemplateArgument *Args,
unsigned NumArgs) {
@@ -246,7 +265,7 @@
}
case Integral:
- getAsIntegral()->Profile(ID);
+ getAsIntegral().Profile(ID);
getIntegralType().Profile(ID);
break;
@@ -275,7 +294,7 @@
case Integral:
return getIntegralType() == Other.getIntegralType() &&
- *getAsIntegral() == *Other.getAsIntegral();
+ getAsIntegral() == Other.getAsIntegral();
case Pack:
if (Args.NumArgs != Other.Args.NumArgs) return false;
@@ -498,7 +517,7 @@
return DB << "nullptr";
case TemplateArgument::Integral:
- return DB << Arg.getAsIntegral()->toString(10);
+ return DB << Arg.getAsIntegral().toString(10);
case TemplateArgument::Template:
return DB << Arg.getAsTemplate();
Modified: cfe/branches/tooling/lib/AST/VTableBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/VTableBuilder.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/VTableBuilder.cpp (original)
+++ cfe/branches/tooling/lib/AST/VTableBuilder.cpp Fri Jun 15 06:08:27 2012
@@ -409,7 +409,7 @@
// Now dump the overriders for this base subobject.
for (CXXRecordDecl::method_iterator I = RD->method_begin(),
E = RD->method_end(); I != E; ++I) {
- const CXXMethodDecl *MD = &*I;
+ const CXXMethodDecl *MD = *I;
if (!MD->isVirtual())
continue;
@@ -692,7 +692,7 @@
// Add the vcall offsets.
for (CXXRecordDecl::method_iterator I = RD->method_begin(),
E = RD->method_end(); I != E; ++I) {
- const CXXMethodDecl *MD = &*I;
+ const CXXMethodDecl *MD = *I;
if (!MD->isVirtual())
continue;
@@ -1469,7 +1469,7 @@
// Now go through all virtual member functions and add them.
for (CXXRecordDecl::method_iterator I = RD->method_begin(),
E = RD->method_end(); I != E; ++I) {
- const CXXMethodDecl *MD = &*I;
+ const CXXMethodDecl *MD = *I;
if (!MD->isVirtual())
continue;
@@ -2105,7 +2105,7 @@
for (CXXRecordDecl::method_iterator i = MostDerivedClass->method_begin(),
e = MostDerivedClass->method_end(); i != e; ++i) {
- const CXXMethodDecl *MD = &*i;
+ const CXXMethodDecl *MD = *i;
// We only want virtual member functions.
if (!MD->isVirtual())
@@ -2217,7 +2217,7 @@
for (CXXRecordDecl::method_iterator i = RD->method_begin(),
e = RD->method_end(); i != e; ++i) {
- const CXXMethodDecl *MD = &*i;
+ const CXXMethodDecl *MD = *i;
// We only want virtual methods.
if (!MD->isVirtual())
Modified: cfe/branches/tooling/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Analysis/CFG.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Analysis/CFG.cpp (original)
+++ cfe/branches/tooling/lib/Analysis/CFG.cpp Fri Jun 15 06:08:27 2012
@@ -832,7 +832,7 @@
if (const CXXRecordDecl *CD = QT->getAsCXXRecordDecl())
if (!CD->hasTrivialDestructor()) {
autoCreateBlock();
- appendMemberDtor(Block, &*FI);
+ appendMemberDtor(Block, *FI);
}
}
}
@@ -3200,8 +3200,8 @@
}
bool CFGImplicitDtor::isNoReturn(ASTContext &astContext) const {
- if (const CXXDestructorDecl *cdecl = getDestructorDecl(astContext)) {
- QualType ty = cdecl->getType();
+ if (const CXXDestructorDecl *decl = getDestructorDecl(astContext)) {
+ QualType ty = decl->getType();
return cast<FunctionType>(ty)->getNoReturnAttr();
}
return false;
Modified: cfe/branches/tooling/lib/Analysis/CallGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Analysis/CallGraph.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Analysis/CallGraph.cpp (original)
+++ cfe/branches/tooling/lib/Analysis/CallGraph.cpp Fri Jun 15 06:08:27 2012
@@ -25,12 +25,11 @@
/// given function body.
class CGBuilder : public StmtVisitor<CGBuilder> {
CallGraph *G;
- const Decl *FD;
CallGraphNode *CallerNode;
public:
- CGBuilder(CallGraph *g, const Decl *D, CallGraphNode *N)
- : G(g), FD(D), CallerNode(N) {}
+ CGBuilder(CallGraph *g, CallGraphNode *N)
+ : G(g), CallerNode(N) {}
void VisitStmt(Stmt *S) { VisitChildren(S); }
@@ -99,7 +98,7 @@
Root->addCallee(Node, this);
// Process all the calls by this function as well.
- CGBuilder builder(this, D, Node);
+ CGBuilder builder(this, Node);
if (Stmt *Body = D->getBody())
builder.Visit(Body);
}
Modified: cfe/branches/tooling/lib/Analysis/UninitializedValues.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Analysis/UninitializedValues.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Analysis/UninitializedValues.cpp (original)
+++ cfe/branches/tooling/lib/Analysis/UninitializedValues.cpp Fri Jun 15 06:08:27 2012
@@ -61,7 +61,7 @@
DeclContext::specific_decl_iterator<VarDecl> I(dc.decls_begin()),
E(dc.decls_end());
for ( ; I != E; ++I) {
- const VarDecl *vd = &*I;
+ const VarDecl *vd = *I;
if (isTrackedVar(vd, &dc))
map[vd] = count++;
}
Modified: cfe/branches/tooling/lib/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Basic/SourceManager.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Basic/SourceManager.cpp (original)
+++ cfe/branches/tooling/lib/Basic/SourceManager.cpp Fri Jun 15 06:08:27 2012
@@ -191,7 +191,7 @@
/// AddLineNote - Add a line note to the line table that indicates that there
/// is a #line at the specified FID/Offset location which changes the presumed
/// location to LineNo/FilenameID.
-void LineTableInfo::AddLineNote(int FID, unsigned Offset,
+void LineTableInfo::AddLineNote(FileID FID, unsigned Offset,
unsigned LineNo, int FilenameID) {
std::vector<LineEntry> &Entries = LineEntries[FID];
@@ -222,7 +222,7 @@
/// presumed #include stack. If it is 1, this is a file entry, if it is 2 then
/// this is a file exit. FileKind specifies whether this is a system header or
/// extern C system header.
-void LineTableInfo::AddLineNote(int FID, unsigned Offset,
+void LineTableInfo::AddLineNote(FileID FID, unsigned Offset,
unsigned LineNo, int FilenameID,
unsigned EntryExit,
SrcMgr::CharacteristicKind FileKind) {
@@ -256,7 +256,7 @@
/// FindNearestLineEntry - Find the line entry nearest to FID that is before
/// it. If there is no line entry before Offset in FID, return null.
-const LineEntry *LineTableInfo::FindNearestLineEntry(int FID,
+const LineEntry *LineTableInfo::FindNearestLineEntry(FileID FID,
unsigned Offset) {
const std::vector<LineEntry> &Entries = LineEntries[FID];
assert(!Entries.empty() && "No #line entries for this FID after all!");
@@ -275,7 +275,7 @@
/// \brief Add a new line entry that has already been encoded into
/// the internal representation of the line table.
-void LineTableInfo::AddEntry(int FID,
+void LineTableInfo::AddEntry(FileID FID,
const std::vector<LineEntry> &Entries) {
LineEntries[FID] = Entries;
}
@@ -308,7 +308,7 @@
if (LineTable == 0)
LineTable = new LineTableInfo();
- LineTable->AddLineNote(LocInfo.first.ID, LocInfo.second, LineNo, FilenameID);
+ LineTable->AddLineNote(LocInfo.first, LocInfo.second, LineNo, FilenameID);
}
/// AddLineNote - Add a GNU line marker to the line table.
@@ -353,7 +353,7 @@
else if (IsFileExit)
EntryExit = 2;
- LineTable->AddLineNote(LocInfo.first.ID, LocInfo.second, LineNo, FilenameID,
+ LineTable->AddLineNote(LocInfo.first, LocInfo.second, LineNo, FilenameID,
EntryExit, FileKind);
}
@@ -407,6 +407,7 @@
void SourceManager::clearIDTables() {
MainFileID = FileID();
+ PredefinesFileID = FileID();
LocalSLocEntryTable.clear();
LoadedSLocEntryTable.clear();
SLocEntryLoaded.clear();
@@ -1314,7 +1315,7 @@
assert(LineTable && "Can't have linetable entries without a LineTable!");
// See if there is a #line directive before the location.
const LineEntry *Entry =
- LineTable->FindNearestLineEntry(LocInfo.first.ID, LocInfo.second);
+ LineTable->FindNearestLineEntry(LocInfo.first, LocInfo.second);
// If this is before the first line marker, use the file characteristic.
if (!Entry)
@@ -1379,7 +1380,7 @@
assert(LineTable && "Can't have linetable entries without a LineTable!");
// See if there is a #line directive before this. If so, get it.
if (const LineEntry *Entry =
- LineTable->FindNearestLineEntry(LocInfo.first.ID, LocInfo.second)) {
+ LineTable->FindNearestLineEntry(LocInfo.first, LocInfo.second)) {
// If the LineEntry indicates a filename, use it.
if (Entry->FilenameID != -1)
Filename = LineTable->getFilename(Entry->FilenameID);
Modified: cfe/branches/tooling/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Basic/Targets.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Basic/Targets.cpp (original)
+++ cfe/branches/tooling/lib/Basic/Targets.cpp Fri Jun 15 06:08:27 2012
@@ -575,12 +575,47 @@
static const Builtin::Info BuiltinInfo[];
static const char * const GCCRegNames[];
static const TargetInfo::GCCRegAlias GCCRegAliases[];
+ std::string CPU;
public:
PPCTargetInfo(const std::string& triple) : TargetInfo(triple) {
LongDoubleWidth = LongDoubleAlign = 128;
LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble;
}
+ virtual bool setCPU(const std::string &Name) {
+ bool CPUKnown = llvm::StringSwitch<bool>(Name)
+ .Case("generic", true)
+ .Case("440", true)
+ .Case("450", true)
+ .Case("601", true)
+ .Case("602", true)
+ .Case("603", true)
+ .Case("603e", true)
+ .Case("603ev", true)
+ .Case("604", true)
+ .Case("604e", true)
+ .Case("620", true)
+ .Case("g3", true)
+ .Case("7400", true)
+ .Case("g4", true)
+ .Case("7450", true)
+ .Case("g4+", true)
+ .Case("750", true)
+ .Case("970", true)
+ .Case("g5", true)
+ .Case("a2", true)
+ .Case("pwr6", true)
+ .Case("pwr7", true)
+ .Case("ppc", true)
+ .Case("ppc64", true)
+ .Default(false);
+
+ if (CPUKnown)
+ CPU = Name;
+
+ return CPUKnown;
+ }
+
virtual void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const {
Records = BuiltinInfo;
@@ -744,6 +779,20 @@
Builder.defineMacro("__VEC__", "10206");
Builder.defineMacro("__ALTIVEC__");
}
+
+ // CPU identification.
+ if (CPU == "440") {
+ Builder.defineMacro("_ARCH_440");
+ } else if (CPU == "450") {
+ Builder.defineMacro("_ARCH_440");
+ Builder.defineMacro("_ARCH_450");
+ } else if (CPU == "970") {
+ Builder.defineMacro("_ARCH_970");
+ } else if (CPU == "pwr6") {
+ Builder.defineMacro("_ARCH_PWR6");
+ } else if (CPU == "pwr7") {
+ Builder.defineMacro("_ARCH_PWR7");
+ }
}
bool PPCTargetInfo::hasFeature(StringRef Feature) const {
@@ -1246,6 +1295,7 @@
bool HasSSE4a;
bool HasFMA4;
bool HasFMA;
+ bool HasXOP;
/// \brief Enumeration of all of the X86 CPUs supported by Clang.
///
@@ -1392,7 +1442,7 @@
: TargetInfo(triple), SSELevel(NoSSE), MMX3DNowLevel(NoMMX3DNow),
HasAES(false), HasPCLMUL(false), HasLZCNT(false), HasBMI(false),
HasBMI2(false), HasPOPCNT(false), HasSSE4a(false), HasFMA4(false),
- HasFMA(false), CPU(CK_Generic) {
+ HasFMA(false), HasXOP(false), CPU(CK_Generic) {
BigEndian = false;
LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
}
@@ -1583,6 +1633,7 @@
Features["popcnt"] = false;
Features["fma4"] = false;
Features["fma"] = false;
+ Features["xop"] = false;
// FIXME: This *really* should not be here.
@@ -1700,7 +1751,7 @@
case CK_BDVER1:
case CK_BDVER2:
setFeatureEnabled(Features, "avx", true);
- setFeatureEnabled(Features, "sse4a", true);
+ setFeatureEnabled(Features, "xop", true);
setFeatureEnabled(Features, "aes", true);
setFeatureEnabled(Features, "pclmul", true);
break;
@@ -1767,6 +1818,11 @@
Features["ssse3"] = Features["sse41"] = Features["sse42"] =
Features["popcnt"] = Features["avx"] = Features["sse4a"] =
Features["fma4"] = true;
+ else if (Name == "xop")
+ Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
+ Features["ssse3"] = Features["sse41"] = Features["sse42"] =
+ Features["popcnt"] = Features["avx"] = Features["sse4a"] =
+ Features["fma4"] = Features["xop"] = true;
else if (Name == "sse4a")
Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
Features["sse4a"] = true;
@@ -1786,16 +1842,18 @@
Features["ssse3"] = Features["sse41"] = Features["sse42"] =
Features["sse4a"] = Features["avx"] = Features["avx2"] =
Features["fma"] = Features["fma4"] = Features["aes"] =
- Features["pclmul"] = false;
+ Features["pclmul"] = Features["xop"] = false;
else if (Name == "sse2")
Features["sse2"] = Features["sse3"] = Features["ssse3"] =
Features["sse41"] = Features["sse42"] = Features["sse4a"] =
Features["avx"] = Features["avx2"] = Features["fma"] =
- Features["fma4"] = Features["aes"] = Features["pclmul"] = false;
+ Features["fma4"] = Features["aes"] = Features["pclmul"] =
+ Features["xop"] = false;
else if (Name == "sse3")
Features["sse3"] = Features["ssse3"] = Features["sse41"] =
Features["sse42"] = Features["sse4a"] = Features["avx"] =
- Features["avx2"] = Features["fma"] = Features["fma4"] = false;
+ Features["avx2"] = Features["fma"] = Features["fma4"] =
+ Features["xop"] = false;
else if (Name == "ssse3")
Features["ssse3"] = Features["sse41"] = Features["sse42"] =
Features["avx"] = Features["avx2"] = Features["fma"] = false;
@@ -1815,13 +1873,13 @@
Features["pclmul"] = false;
else if (Name == "avx")
Features["avx"] = Features["avx2"] = Features["fma"] =
- Features["fma4"] = false;
+ Features["fma4"] = Features["xop"] = false;
else if (Name == "avx2")
Features["avx2"] = false;
else if (Name == "fma")
Features["fma"] = false;
else if (Name == "sse4a")
- Features["sse4a"] = Features["fma4"] = false;
+ Features["sse4a"] = Features["fma4"] = Features["xop"] = false;
else if (Name == "lzcnt")
Features["lzcnt"] = false;
else if (Name == "bmi")
@@ -1831,7 +1889,9 @@
else if (Name == "popcnt")
Features["popcnt"] = false;
else if (Name == "fma4")
- Features["fma4"] = false;
+ Features["fma4"] = Features["xop"] = false;
+ else if (Name == "xop")
+ Features["xop"] = false;
}
return true;
@@ -1893,6 +1953,11 @@
continue;
}
+ if (Feature == "xop") {
+ HasXOP = true;
+ continue;
+ }
+
assert(Features[i][0] == '+' && "Invalid target feature!");
X86SSEEnum Level = llvm::StringSwitch<X86SSEEnum>(Feature)
.Case("avx2", AVX2)
@@ -2099,6 +2164,9 @@
if (HasFMA)
Builder.defineMacro("__FMA__");
+ if (HasXOP)
+ Builder.defineMacro("__XOP__");
+
// Each case falls through to the previous one here.
switch (SSELevel) {
case AVX2:
@@ -2180,6 +2248,7 @@
.Case("x86", true)
.Case("x86_32", PointerWidth == 32)
.Case("x86_64", PointerWidth == 64)
+ .Case("xop", HasXOP)
.Default(false);
}
Modified: cfe/branches/tooling/lib/CodeGen/CGCXXABI.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGCXXABI.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGCXXABI.h (original)
+++ cfe/branches/tooling/lib/CodeGen/CGCXXABI.h Fri Jun 15 06:08:27 2012
@@ -38,7 +38,7 @@
class CodeGenFunction;
class CodeGenModule;
-/// Implements C++ ABI-specific code generation functions.
+/// \brief Implements C++ ABI-specific code generation functions.
class CGCXXABI {
protected:
CodeGenModule &CGM;
@@ -251,7 +251,9 @@
///
/// \param ptr - a pointer to the allocation made for an array, as a char*
/// \param cookieSize - the computed cookie size of an array
+ ///
/// Other parameters are as above.
+ ///
/// \return a size_t
virtual llvm::Value *readArrayCookieImpl(CodeGenFunction &IGF,
llvm::Value *ptr,
Modified: cfe/branches/tooling/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGCall.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGCall.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGCall.cpp Fri Jun 15 06:08:27 2012
@@ -431,7 +431,7 @@
for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
i != e; ++i) {
- const FieldDecl *FD = &*i;
+ const FieldDecl *FD = *i;
assert(!FD->isBitField() &&
"Cannot expand structure with bit-field members.");
CharUnits FieldSize = getContext().getTypeSizeInChars(FD->getType());
@@ -445,10 +445,9 @@
} else {
for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
i != e; ++i) {
- const FieldDecl &FD = *i;
- assert(!FD.isBitField() &&
+ assert(!i->isBitField() &&
"Cannot expand structure with bit-field members.");
- GetExpandedTypes(FD.getType(), expandedTypes);
+ GetExpandedTypes(i->getType(), expandedTypes);
}
}
} else if (const ComplexType *CT = type->getAs<ComplexType>()) {
@@ -483,7 +482,7 @@
for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
i != e; ++i) {
- const FieldDecl *FD = &*i;
+ const FieldDecl *FD = *i;
assert(!FD->isBitField() &&
"Cannot expand structure with bit-field members.");
CharUnits FieldSize = getContext().getTypeSizeInChars(FD->getType());
@@ -500,7 +499,7 @@
} else {
for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
i != e; ++i) {
- FieldDecl *FD = &*i;
+ FieldDecl *FD = *i;
QualType FT = FD->getType();
// FIXME: What are the right qualifiers here?
@@ -1815,7 +1814,7 @@
for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
i != e; ++i) {
- const FieldDecl *FD = &*i;
+ const FieldDecl *FD = *i;
assert(!FD->isBitField() &&
"Cannot expand structure with bit-field members.");
CharUnits FieldSize = getContext().getTypeSizeInChars(FD->getType());
@@ -1831,7 +1830,7 @@
} else {
for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
i != e; ++i) {
- FieldDecl *FD = &*i;
+ FieldDecl *FD = *i;
RValue FldRV = EmitRValueForField(LV, FD);
ExpandTypeToArgs(FD->getType(), FldRV, Args, IRFuncTy);
Modified: cfe/branches/tooling/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGClass.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGClass.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGClass.cpp Fri Jun 15 06:08:27 2012
@@ -808,7 +808,7 @@
// Check fields.
for (CXXRecordDecl::field_iterator I = BaseClassDecl->field_begin(),
E = BaseClassDecl->field_end(); I != E; ++I) {
- const FieldDecl *Field = &*I;
+ const FieldDecl *Field = *I;
if (!FieldHasTrivialDestructorBody(Context, Field))
return false;
@@ -869,7 +869,7 @@
const CXXRecordDecl *ClassDecl = Dtor->getParent();
for (CXXRecordDecl::field_iterator I = ClassDecl->field_begin(),
E = ClassDecl->field_end(); I != E; ++I) {
- const FieldDecl *Field = &*I;
+ const FieldDecl *Field = *I;
if (!FieldHasTrivialDestructorBody(Context, Field))
return false;
@@ -1066,7 +1066,7 @@
SmallVector<const FieldDecl *, 16> FieldDecls;
for (CXXRecordDecl::field_iterator I = ClassDecl->field_begin(),
E = ClassDecl->field_end(); I != E; ++I) {
- const FieldDecl *field = &*I;
+ const FieldDecl *field = *I;
QualType type = field->getType();
QualType::DestructionKind dtorKind = type.isDestructedType();
if (!dtorKind) continue;
Modified: cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp Fri Jun 15 06:08:27 2012
@@ -797,7 +797,7 @@
for (RecordDecl::field_iterator I = record->field_begin(),
E = record->field_end();
I != E; ++I, ++fieldNo) {
- FieldDecl *field = &*I;
+ FieldDecl *field = *I;
if (IsMsStruct) {
// Zero-length bitfields following non-bitfield members are ignored
@@ -1086,7 +1086,7 @@
llvm::DIType TTy = getOrCreateType(TA.getIntegralType(), Unit);
llvm::DITemplateValueParameter TVP =
DBuilder.createTemplateValueParameter(TheCU, ND->getName(), TTy,
- TA.getAsIntegral()->getZExtValue());
+ TA.getAsIntegral().getZExtValue());
TemplateParams.push_back(TVP);
}
}
@@ -1338,7 +1338,7 @@
for (ObjCContainerDecl::prop_iterator I = ID->prop_begin(),
E = ID->prop_end(); I != E; ++I) {
- const ObjCPropertyDecl *PD = &*I;
+ const ObjCPropertyDecl *PD = *I;
SourceLocation Loc = PD->getLocation();
llvm::DIFile PUnit = getOrCreateFile(Loc);
unsigned PLine = getLineNumber(Loc);
@@ -1565,7 +1565,6 @@
/// CreateEnumType - get enumeration type.
llvm::DIType CGDebugInfo::CreateEnumType(const EnumDecl *ED) {
- llvm::DIFile Unit = getOrCreateFile(ED->getLocation());
SmallVector<llvm::Value *, 16> Enumerators;
// Create DIEnumerator elements for each enumerator.
@@ -1700,7 +1699,8 @@
llvm::DIType TC = getTypeOrNull(Ty);
if (TC.Verify() && TC.isForwardDecl())
- ReplaceMap.push_back(std::make_pair(Ty.getAsOpaquePtr(), TC));
+ ReplaceMap.push_back(std::make_pair(Ty.getAsOpaquePtr(),
+ static_cast<llvm::Value*>(TC)));
// And update the type cache.
TypeCache[Ty.getAsOpaquePtr()] = Res;
@@ -1811,7 +1811,8 @@
llvm::DIType Res = CreateLimitedTypeNode(Ty, Unit);
if (T.Verify() && T.isForwardDecl())
- ReplaceMap.push_back(std::make_pair(Ty.getAsOpaquePtr(), T));
+ ReplaceMap.push_back(std::make_pair(Ty.getAsOpaquePtr(),
+ static_cast<llvm::Value*>(T)));
// And update the type cache.
TypeCache[Ty.getAsOpaquePtr()] = Res;
@@ -2332,7 +2333,7 @@
for (RecordDecl::field_iterator I = RD->field_begin(),
E = RD->field_end();
I != E; ++I) {
- FieldDecl *Field = &*I;
+ FieldDecl *Field = *I;
llvm::DIType FieldTy = getOrCreateType(Field->getType(), Unit);
StringRef FieldName = Field->getName();
Modified: cfe/branches/tooling/lib/CodeGen/CGException.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGException.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGException.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGException.cpp Fri Jun 15 06:08:27 2012
@@ -1127,14 +1127,6 @@
CGF.EmitAutoVarCleanups(var);
}
-namespace {
- struct CallRethrow : EHScopeStack::Cleanup {
- void Emit(CodeGenFunction &CGF, Flags flags) {
- CGF.EmitCallOrInvoke(getReThrowFn(CGF));
- }
- };
-}
-
/// Emit the structure of the dispatch block for the given catch scope.
/// It is an invariant that the dispatch block already exists.
static void emitCatchDispatchBlock(CodeGenFunction &CGF,
@@ -1246,11 +1238,12 @@
if (HaveInsertPoint())
Builder.CreateBr(ContBB);
- // Determine if we need an implicit rethrow for all these catch handlers.
- bool ImplicitRethrow = false;
+ // Determine if we need an implicit rethrow for all these catch handlers;
+ // see the comment below.
+ bool doImplicitRethrow = false;
if (IsFnTryBlock)
- ImplicitRethrow = isa<CXXDestructorDecl>(CurCodeDecl) ||
- isa<CXXConstructorDecl>(CurCodeDecl);
+ doImplicitRethrow = isa<CXXDestructorDecl>(CurCodeDecl) ||
+ isa<CXXConstructorDecl>(CurCodeDecl);
// Perversely, we emit the handlers backwards precisely because we
// want them to appear in source order. In all of these cases, the
@@ -1273,15 +1266,24 @@
// Initialize the catch variable and set up the cleanups.
BeginCatch(*this, C);
- // If there's an implicit rethrow, push a normal "cleanup" to call
- // _cxa_rethrow. This needs to happen before __cxa_end_catch is
- // called, and so it is pushed after BeginCatch.
- if (ImplicitRethrow)
- EHStack.pushCleanup<CallRethrow>(NormalCleanup);
-
// Perform the body of the catch.
EmitStmt(C->getHandlerBlock());
+ // [except.handle]p11:
+ // The currently handled exception is rethrown if control
+ // reaches the end of a handler of the function-try-block of a
+ // constructor or destructor.
+
+ // It is important that we only do this on fallthrough and not on
+ // return. Note that it's illegal to put a return in a
+ // constructor function-try-block's catch handler (p14), so this
+ // really only applies to destructors.
+ if (doImplicitRethrow && HaveInsertPoint()) {
+ EmitCallOrInvoke(getReThrowFn(*this));
+ Builder.CreateUnreachable();
+ Builder.ClearInsertionPoint();
+ }
+
// Fall out through the catch cleanups.
CatchScope.ForceCleanup();
Modified: cfe/branches/tooling/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGExpr.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGExpr.cpp Fri Jun 15 06:08:27 2012
@@ -2114,7 +2114,10 @@
llvm::Value *GlobalPtr = CGM.GetAddrOfConstantCompoundLiteral(E);
return MakeAddrLValue(GlobalPtr, E->getType());
}
-
+ if (E->getType()->isVariablyModifiedType())
+ // make sure to emit the VLA size.
+ EmitVariablyModifiedType(E->getType());
+
llvm::Value *DeclPtr = CreateMemTemp(E->getType(), ".compoundliteral");
const Expr *InitExpr = E->getInitializer();
LValue Result = MakeAddrLValue(DeclPtr, E->getType());
Modified: cfe/branches/tooling/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGExprAgg.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGExprAgg.cpp Fri Jun 15 06:08:27 2012
@@ -352,7 +352,7 @@
return;
}
LValue DestLV = CGF.MakeNaturalAlignAddrLValue(destPtr, initList->getType());
- LValue start = CGF.EmitLValueForFieldInitialization(DestLV, &*field);
+ LValue start = CGF.EmitLValueForFieldInitialization(DestLV, *field);
llvm::Value *arrayStart = Builder.CreateStructGEP(alloc, 0, "arraystart");
CGF.EmitStoreThroughLValue(RValue::get(arrayStart), start);
++field;
@@ -361,7 +361,7 @@
CGF.ErrorUnsupported(initList, "weird std::initializer_list");
return;
}
- LValue endOrLength = CGF.EmitLValueForFieldInitialization(DestLV, &*field);
+ LValue endOrLength = CGF.EmitLValueForFieldInitialization(DestLV, *field);
if (ctx.hasSameType(field->getType(), elementPtr)) {
// End pointer.
llvm::Value *arrayEnd = Builder.CreateStructGEP(alloc,numInits, "arrayend");
@@ -1005,7 +1005,7 @@
break;
- LValue LV = CGF.EmitLValueForFieldInitialization(DestLV, &*field);
+ LValue LV = CGF.EmitLValueForFieldInitialization(DestLV, *field);
// We never generate write-barries for initialized fields.
LV.setNonGC(true);
Modified: cfe/branches/tooling/lib/CodeGen/CGExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGExprCXX.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGExprCXX.cpp Fri Jun 15 06:08:27 2012
@@ -1823,10 +1823,10 @@
i != e; ++i, ++CurField) {
// Emit initialization
- LValue LV = EmitLValueForFieldInitialization(SlotLV, &*CurField);
+ LValue LV = EmitLValueForFieldInitialization(SlotLV, *CurField);
ArrayRef<VarDecl *> ArrayIndexes;
if (CurField->getType()->isArrayType())
ArrayIndexes = E->getCaptureInitIndexVars(i);
- EmitInitializerForField(&*CurField, LV, *i, ArrayIndexes);
+ EmitInitializerForField(*CurField, LV, *i, ArrayIndexes);
}
}
Modified: cfe/branches/tooling/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGExprConstant.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGExprConstant.cpp Fri Jun 15 06:08:27 2012
@@ -386,20 +386,20 @@
if (IsMsStruct) {
// Zero-length bitfields following non-bitfield members are
// ignored:
- if (CGM.getContext().ZeroBitfieldFollowsNonBitfield(&*Field, LastFD)) {
+ if (CGM.getContext().ZeroBitfieldFollowsNonBitfield(*Field, LastFD)) {
--FieldNo;
continue;
}
- LastFD = &*Field;
+ LastFD = *Field;
}
// If this is a union, skip all the fields that aren't being initialized.
- if (RD->isUnion() && ILE->getInitializedFieldInUnion() != &*Field)
+ if (RD->isUnion() && ILE->getInitializedFieldInUnion() != *Field)
continue;
// Don't emit anonymous bitfields, they just affect layout.
if (Field->isUnnamedBitfield()) {
- LastFD = &*Field;
+ LastFD = *Field;
continue;
}
@@ -417,10 +417,10 @@
if (!Field->isBitField()) {
// Handle non-bitfield members.
- AppendField(&*Field, Layout.getFieldOffset(FieldNo), EltInit);
+ AppendField(*Field, Layout.getFieldOffset(FieldNo), EltInit);
} else {
// Otherwise we have a bitfield.
- AppendBitField(&*Field, Layout.getFieldOffset(FieldNo),
+ AppendBitField(*Field, Layout.getFieldOffset(FieldNo),
cast<llvm::ConstantInt>(EltInit));
}
}
@@ -486,20 +486,20 @@
if (IsMsStruct) {
// Zero-length bitfields following non-bitfield members are
// ignored:
- if (CGM.getContext().ZeroBitfieldFollowsNonBitfield(&*Field, LastFD)) {
+ if (CGM.getContext().ZeroBitfieldFollowsNonBitfield(*Field, LastFD)) {
--FieldNo;
continue;
}
- LastFD = &*Field;
+ LastFD = *Field;
}
// If this is a union, skip all the fields that aren't being initialized.
- if (RD->isUnion() && Val.getUnionField() != &*Field)
+ if (RD->isUnion() && Val.getUnionField() != *Field)
continue;
// Don't emit anonymous bitfields, they just affect layout.
if (Field->isUnnamedBitfield()) {
- LastFD = &*Field;
+ LastFD = *Field;
continue;
}
@@ -512,10 +512,10 @@
if (!Field->isBitField()) {
// Handle non-bitfield members.
- AppendField(&*Field, Layout.getFieldOffset(FieldNo) + OffsetBits, EltInit);
+ AppendField(*Field, Layout.getFieldOffset(FieldNo) + OffsetBits, EltInit);
} else {
// Otherwise we have a bitfield.
- AppendBitField(&*Field, Layout.getFieldOffset(FieldNo) + OffsetBits,
+ AppendBitField(*Field, Layout.getFieldOffset(FieldNo) + OffsetBits,
cast<llvm::ConstantInt>(EltInit));
}
}
@@ -1374,7 +1374,7 @@
// Fill in all the fields.
for (RecordDecl::field_iterator I = record->field_begin(),
E = record->field_end(); I != E; ++I) {
- const FieldDecl *field = &*I;
+ const FieldDecl *field = *I;
// Fill in non-bitfields. (Bitfields always use a zero pattern, which we
// will fill in later.)
Modified: cfe/branches/tooling/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGExprScalar.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGExprScalar.cpp Fri Jun 15 06:08:27 2012
@@ -1522,7 +1522,7 @@
for (RecordDecl::field_iterator Field = RD->field_begin(),
FieldEnd = RD->field_end();
Field != FieldEnd; ++Field, ++i) {
- if (&*Field == MemberDecl)
+ if (*Field == MemberDecl)
break;
}
assert(i < RL.getFieldCount() && "offsetof field in wrong type");
Modified: cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp Fri Jun 15 06:08:27 2012
@@ -292,8 +292,8 @@
protected:
/// Function used for throwing Objective-C exceptions.
LazyRuntimeFunction ExceptionThrowFn;
- /// Function used for rethrowing exceptions, used at the end of @finally or
- /// @synchronize blocks.
+ /// Function used for rethrowing exceptions, used at the end of \@finally or
+ /// \@synchronize blocks.
LazyRuntimeFunction ExceptionReThrowFn;
/// Function called when entering a catch function. This is required for
/// differentiating Objective-C exceptions and foreign exceptions.
@@ -301,9 +301,9 @@
/// Function called when exiting from a catch block. Used to do exception
/// cleanup.
LazyRuntimeFunction ExitCatchFn;
- /// Function called when entering an @synchronize block. Acquires the lock.
+ /// Function called when entering an \@synchronize block. Acquires the lock.
LazyRuntimeFunction SyncEnterFn;
- /// Function called when exiting an @synchronize block. Releases the lock.
+ /// Function called when exiting an \@synchronize block. Releases the lock.
LazyRuntimeFunction SyncExitFn;
private:
@@ -350,7 +350,7 @@
ArrayRef<Selector> MethodSels,
ArrayRef<llvm::Constant *> MethodTypes,
bool isClassMethodList);
- /// Emits an empty protocol. This is used for @protocol() where no protocol
+ /// Emits an empty protocol. This is used for \@protocol() where no protocol
/// is found. The runtime will (hopefully) fix up the pointer to refer to the
/// real protocol.
llvm::Constant *GenerateEmptyProtocol(const std::string &ProtocolName);
@@ -1627,7 +1627,7 @@
iter = PD->prop_begin(), endIter = PD->prop_end();
iter != endIter ; iter++) {
std::vector<llvm::Constant*> Fields;
- ObjCPropertyDecl *property = &*iter;
+ ObjCPropertyDecl *property = *iter;
Fields.push_back(MakeConstantString(property->getNameAsString()));
Fields.push_back(llvm::ConstantInt::get(Int8Ty,
@@ -1878,7 +1878,7 @@
iter != endIter ; iter++) {
std::vector<llvm::Constant*> Fields;
ObjCPropertyDecl *property = iter->getPropertyDecl();
- ObjCPropertyImplDecl *propertyImpl = &*iter;
+ ObjCPropertyImplDecl *propertyImpl = *iter;
bool isSynthesized = (propertyImpl->getPropertyImplementation() ==
ObjCPropertyImplDecl::Synthesize);
Modified: cfe/branches/tooling/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGObjCMac.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGObjCMac.cpp Fri Jun 15 06:08:27 2012
@@ -2121,7 +2121,7 @@
PushProtocolProperties(PropertySet, Properties, Container, (*P), ObjCTypes);
for (ObjCContainerDecl::prop_iterator I = PROTO->prop_begin(),
E = PROTO->prop_end(); I != E; ++I) {
- const ObjCPropertyDecl *PD = &*I;
+ const ObjCPropertyDecl *PD = *I;
if (!PropertySet.insert(PD->getIdentifier()))
continue;
llvm::Constant *Prop[] = {
@@ -2152,7 +2152,7 @@
llvm::SmallPtrSet<const IdentifierInfo*, 16> PropertySet;
for (ObjCContainerDecl::prop_iterator I = OCD->prop_begin(),
E = OCD->prop_end(); I != E; ++I) {
- const ObjCPropertyDecl *PD = &*I;
+ const ObjCPropertyDecl *PD = *I;
PropertySet.insert(PD->getIdentifier());
llvm::Constant *Prop[] = {
GetPropertyName(PD->getIdentifier()),
@@ -2403,7 +2403,7 @@
for (ObjCImplementationDecl::propimpl_iterator
i = ID->propimpl_begin(), e = ID->propimpl_end(); i != e; ++i) {
- ObjCPropertyImplDecl *PID = &*i;
+ ObjCPropertyImplDecl *PID = *i;
if (PID->getPropertyImplementation() == ObjCPropertyImplDecl::Synthesize) {
ObjCPropertyDecl *PD = PID->getPropertyDecl();
@@ -3821,7 +3821,7 @@
SmallVector<const FieldDecl*, 16> Fields;
for (RecordDecl::field_iterator i = RD->field_begin(),
e = RD->field_end(); i != e; ++i)
- Fields.push_back(&*i);
+ Fields.push_back(*i);
llvm::Type *Ty = CGM.getTypes().ConvertType(QualType(RT, 0));
const llvm::StructLayout *RecLayout =
CGM.getTargetData().getStructLayout(cast<llvm::StructType>(Ty));
@@ -4386,9 +4386,10 @@
SourceLocation(), SourceLocation(),
&Ctx.Idents.get("_objc_super"));
RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), SourceLocation(), 0,
- Ctx.getObjCIdType(), 0, 0, false, false));
+ Ctx.getObjCIdType(), 0, 0, false, ICIS_NoInit));
RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), SourceLocation(), 0,
- Ctx.getObjCClassType(), 0, 0, false, false));
+ Ctx.getObjCClassType(), 0, 0, false,
+ ICIS_NoInit));
RD->completeDefinition();
SuperCTy = Ctx.getTagDeclType(RD);
@@ -4767,9 +4768,10 @@
SourceLocation(), SourceLocation(),
&Ctx.Idents.get("_message_ref_t"));
RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), SourceLocation(), 0,
- Ctx.VoidPtrTy, 0, 0, false, false));
+ Ctx.VoidPtrTy, 0, 0, false, ICIS_NoInit));
RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), SourceLocation(), 0,
- Ctx.getObjCSelType(), 0, 0, false, false));
+ Ctx.getObjCSelType(), 0, 0, false,
+ ICIS_NoInit));
RD->completeDefinition();
MessageRefCTy = Ctx.getTagDeclType(RD);
@@ -5004,7 +5006,7 @@
}
for (ObjCImplementationDecl::propimpl_iterator
i = ID->propimpl_begin(), e = ID->propimpl_end(); i != e; ++i) {
- ObjCPropertyImplDecl *PID = &*i;
+ ObjCPropertyImplDecl *PID = *i;
if (PID->getPropertyImplementation() == ObjCPropertyImplDecl::Synthesize){
ObjCPropertyDecl *PD = PID->getPropertyDecl();
Modified: cfe/branches/tooling/lib/CodeGen/CGObjCRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGObjCRuntime.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGObjCRuntime.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGObjCRuntime.cpp Fri Jun 15 06:08:27 2012
@@ -334,7 +334,7 @@
///
/// \param method - may be null
/// \param resultType - the result type to use if there's no method
-/// \param argInfo - the actual arguments, including implicit ones
+/// \param callArgs - the actual arguments, including implicit ones
CGObjCRuntime::MessageSendInfo
CGObjCRuntime::getMessageSendInfo(const ObjCMethodDecl *method,
QualType resultType,
Modified: cfe/branches/tooling/lib/CodeGen/CGObjCRuntime.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGObjCRuntime.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGObjCRuntime.h (original)
+++ cfe/branches/tooling/lib/CodeGen/CGObjCRuntime.h Fri Jun 15 06:08:27 2012
@@ -179,7 +179,7 @@
const ObjCMethodDecl *Method = 0) = 0;
/// Emit the code to return the named protocol as an object, as in a
- /// @protocol expression.
+ /// \@protocol expression.
virtual llvm::Value *GenerateProtocolRef(CGBuilderTy &Builder,
const ObjCProtocolDecl *OPD) = 0;
Modified: cfe/branches/tooling/lib/CodeGen/CGRecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGRecordLayoutBuilder.cpp Fri Jun 15 06:08:27 2012
@@ -538,7 +538,7 @@
fieldEnd = D->field_end(); field != fieldEnd; ++field, ++fieldNo) {
assert(layout.getFieldOffset(fieldNo) == 0 &&
"Union field offset did not start at the beginning of record!");
- llvm::Type *fieldType = LayoutUnionField(&*field, layout);
+ llvm::Type *fieldType = LayoutUnionField(*field, layout);
if (!fieldType)
continue;
@@ -818,7 +818,7 @@
if (IsMsStruct) {
// Zero-length bitfields following non-bitfield members are
// ignored:
- const FieldDecl *FD = &*Field;
+ const FieldDecl *FD = *Field;
if (Types.getContext().ZeroBitfieldFollowsNonBitfield(FD, LastFD)) {
--FieldNo;
continue;
@@ -826,7 +826,7 @@
LastFD = FD;
}
- if (!LayoutField(&*Field, Layout.getFieldOffset(FieldNo))) {
+ if (!LayoutField(*Field, Layout.getFieldOffset(FieldNo))) {
assert(!Packed &&
"Could not layout fields even with a packed LLVM struct!");
return false;
@@ -1061,7 +1061,7 @@
const FieldDecl *LastFD = 0;
bool IsMsStruct = D->hasAttr<MsStructAttr>();
for (unsigned i = 0, e = AST_RL.getFieldCount(); i != e; ++i, ++it) {
- const FieldDecl *FD = &*it;
+ const FieldDecl *FD = *it;
// For non-bit-fields, just check that the LLVM struct offset matches the
// AST offset.
@@ -1122,7 +1122,7 @@
const RecordDecl *RD = it->first->getParent();
unsigned Index = 0;
for (RecordDecl::field_iterator
- it2 = RD->field_begin(); &*it2 != it->first; ++it2)
+ it2 = RD->field_begin(); *it2 != it->first; ++it2)
++Index;
BFIs.push_back(std::make_pair(Index, &it->second));
}
Modified: cfe/branches/tooling/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGStmt.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGStmt.cpp Fri Jun 15 06:08:27 2012
@@ -133,6 +133,7 @@
case Stmt::SwitchStmtClass: EmitSwitchStmt(cast<SwitchStmt>(*S)); break;
case Stmt::AsmStmtClass: EmitAsmStmt(cast<AsmStmt>(*S)); break;
+ case Stmt::MSAsmStmtClass: EmitMSAsmStmt(cast<MSAsmStmt>(*S)); break;
case Stmt::ObjCAtTryStmtClass:
EmitObjCAtTryStmt(cast<ObjCAtTryStmt>(*S));
@@ -1681,3 +1682,8 @@
EmitStoreThroughLValue(RValue::get(Tmp), ResultRegDests[i]);
}
}
+
+void CodeGenFunction::EmitMSAsmStmt(const MSAsmStmt &S) {
+ // Analyze the asm string to decompose it into its pieces.
+ llvm::report_fatal_error("MS-style asm codegen isn't yet supported.");
+}
Modified: cfe/branches/tooling/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenFunction.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenFunction.h Fri Jun 15 06:08:27 2012
@@ -1970,6 +1970,7 @@
void EmitCaseStmt(const CaseStmt &S);
void EmitCaseStmtRange(const CaseStmt &S);
void EmitAsmStmt(const AsmStmt &S);
+ void EmitMSAsmStmt(const MSAsmStmt &S);
void EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S);
void EmitObjCAtTryStmt(const ObjCAtTryStmt &S);
Modified: cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp Fri Jun 15 06:08:27 2012
@@ -2127,7 +2127,7 @@
FieldTypes[i], /*TInfo=*/0,
/*BitWidth=*/0,
/*Mutable=*/false,
- /*HasInit=*/false);
+ ICIS_NoInit);
Field->setAccess(AS_public);
D->addDecl(Field);
}
@@ -2202,7 +2202,7 @@
FieldTypes[i], /*TInfo=*/0,
/*BitWidth=*/0,
/*Mutable=*/false,
- /*HasInit=*/false);
+ ICIS_NoInit);
Field->setAccess(AS_public);
D->addDecl(Field);
}
@@ -2365,7 +2365,7 @@
ObjCImplementationDecl *D) {
for (ObjCImplementationDecl::propimpl_iterator
i = D->propimpl_begin(), e = D->propimpl_end(); i != e; ++i) {
- ObjCPropertyImplDecl *PID = &*i;
+ ObjCPropertyImplDecl *PID = *i;
// Dynamic is just for type-checking.
if (PID->getPropertyImplementation() == ObjCPropertyImplDecl::Synthesize) {
Modified: cfe/branches/tooling/lib/CodeGen/CodeGenTBAA.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenTBAA.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenTBAA.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenTBAA.cpp Fri Jun 15 06:08:27 2012
@@ -29,8 +29,7 @@
CodeGenTBAA::CodeGenTBAA(ASTContext &Ctx, llvm::LLVMContext& VMContext,
const CodeGenOptions &CGO,
const LangOptions &Features, MangleContext &MContext)
- : Context(Ctx), VMContext(VMContext), CodeGenOpts(CGO),
- Features(Features), MContext(MContext),
+ : Context(Ctx), CodeGenOpts(CGO), Features(Features), MContext(MContext),
MDHelper(VMContext), Root(0), Char(0) {
}
Modified: cfe/branches/tooling/lib/CodeGen/CodeGenTBAA.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenTBAA.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenTBAA.h (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenTBAA.h Fri Jun 15 06:08:27 2012
@@ -39,7 +39,6 @@
/// while lowering AST types to LLVM types.
class CodeGenTBAA {
ASTContext &Context;
- llvm::LLVMContext& VMContext;
const CodeGenOptions &CodeGenOpts;
const LangOptions &Features;
MangleContext &MContext;
Modified: cfe/branches/tooling/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/TargetInfo.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/TargetInfo.cpp Fri Jun 15 06:08:27 2012
@@ -161,7 +161,7 @@
for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
i != e; ++i)
- if (!isEmptyField(Context, &*i, AllowArrays))
+ if (!isEmptyField(Context, *i, AllowArrays))
return false;
return true;
}
@@ -229,7 +229,7 @@
// Check for single element.
for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
i != e; ++i) {
- const FieldDecl *FD = &*i;
+ const FieldDecl *FD = *i;
QualType FT = FD->getType();
// Ignore empty fields.
@@ -301,7 +301,7 @@
for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
i != e; ++i) {
- const FieldDecl *FD = &*i;
+ const FieldDecl *FD = *i;
if (!is32Or64BitBasicType(FD->getType(), Context))
return false;
@@ -534,7 +534,7 @@
// passed in a register.
for (RecordDecl::field_iterator i = RT->getDecl()->field_begin(),
e = RT->getDecl()->field_end(); i != e; ++i) {
- const FieldDecl *FD = &*i;
+ const FieldDecl *FD = *i;
// Empty fields are ignored.
if (isEmptyField(Context, FD, true))
@@ -2603,7 +2603,7 @@
Members = 0;
for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
i != e; ++i) {
- const FieldDecl *FD = &*i;
+ const FieldDecl *FD = *i;
uint64_t FldMembers;
if (!isHomogeneousAggregate(FD->getType(), Base, Context, &FldMembers))
return false;
@@ -2746,7 +2746,7 @@
unsigned idx = 0;
for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
i != e; ++i, ++idx) {
- const FieldDecl *FD = &*i;
+ const FieldDecl *FD = *i;
// Bit-fields are not addressable, we only need to verify they are "integer
// like". We still have to disallow a subsequent non-bitfield, for example:
Modified: cfe/branches/tooling/lib/Driver/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/CMakeLists.txt?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/CMakeLists.txt (original)
+++ cfe/branches/tooling/lib/Driver/CMakeLists.txt Fri Jun 15 06:08:27 2012
@@ -20,13 +20,6 @@
Types.cpp
)
-IF(MSVC)
- get_target_property(NON_ANSI_COMPILE_FLAGS clangDriver COMPILE_FLAGS)
- string(REPLACE /Za
- "" NON_ANSI_COMPILE_FLAGS
- ${NON_ANSI_COMPILE_FLAGS})
- set_target_properties(clangDriver PROPERTIES COMPILE_FLAGS ${NON_ANSI_COMPILE_FLAGS})
-ENDIF(MSVC)
add_dependencies(clangDriver ClangAttrList ClangDiagnosticDriver
ClangDriverOptions ClangCC1AsOptions)
Modified: cfe/branches/tooling/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/Tools.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/Tools.cpp (original)
+++ cfe/branches/tooling/lib/Driver/Tools.cpp Fri Jun 15 06:08:27 2012
@@ -902,6 +902,72 @@
}
}
+/// getPPCTargetCPU - Get the (LLVM) name of the PowerPC cpu we are targeting.
+static std::string getPPCTargetCPU(const ArgList &Args) {
+ if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
+ StringRef CPUName = A->getValue(Args);
+
+ if (CPUName == "native") {
+ std::string CPU = llvm::sys::getHostCPUName();
+ if (!CPU.empty() && CPU != "generic")
+ return CPU;
+ else
+ return "";
+ }
+
+ return llvm::StringSwitch<const char *>(CPUName)
+ .Case("common", "generic")
+ .Case("440", "440")
+ .Case("440fp", "440")
+ .Case("450", "450")
+ .Case("601", "601")
+ .Case("602", "602")
+ .Case("603", "603")
+ .Case("603e", "603e")
+ .Case("603ev", "603ev")
+ .Case("604", "604")
+ .Case("604e", "604e")
+ .Case("620", "620")
+ .Case("G3", "g3")
+ .Case("7400", "7400")
+ .Case("G4", "g4")
+ .Case("7450", "7450")
+ .Case("G4+", "g4+")
+ .Case("750", "750")
+ .Case("970", "970")
+ .Case("G5", "g5")
+ .Case("a2", "a2")
+ .Case("power6", "pwr6")
+ .Case("power7", "pwr7")
+ .Case("powerpc", "ppc")
+ .Case("powerpc64", "ppc64")
+ .Default("");
+ }
+
+ return "";
+}
+
+void Clang::AddPPCTargetArgs(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+ std::string TargetCPUName = getPPCTargetCPU(Args);
+
+ // LLVM may default to generating code for the native CPU,
+ // but, like gcc, we default to a more generic option for
+ // each architecture. (except on Darwin)
+ llvm::Triple Triple = getToolChain().getTriple();
+ if (TargetCPUName.empty() && !Triple.isOSDarwin()) {
+ if (Triple.getArch() == llvm::Triple::ppc64)
+ TargetCPUName = "ppc64";
+ else
+ TargetCPUName = "ppc";
+ }
+
+ if (!TargetCPUName.empty()) {
+ CmdArgs.push_back("-target-cpu");
+ CmdArgs.push_back(Args.MakeArgString(TargetCPUName.c_str()));
+ }
+}
+
void Clang::AddSparcTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
const Driver &D = getToolChain().getDriver();
@@ -1778,6 +1844,11 @@
AddMIPSTargetArgs(Args, CmdArgs);
break;
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
+ AddPPCTargetArgs(Args, CmdArgs);
+ break;
+
case llvm::Triple::sparc:
AddSparcTargetArgs(Args, CmdArgs);
break;
@@ -1963,7 +2034,8 @@
}
Args.AddAllArgs(CmdArgs, options::OPT_W_Group);
- Args.AddLastArg(CmdArgs, options::OPT_pedantic);
+ if (Args.hasFlag(options::OPT_pedantic, options::OPT_no_pedantic, false))
+ CmdArgs.push_back("-pedantic");
Args.AddLastArg(CmdArgs, options::OPT_pedantic_errors);
Args.AddLastArg(CmdArgs, options::OPT_w);
@@ -2161,6 +2233,10 @@
if (Args.getLastArg(options::OPT_fapple_kext))
CmdArgs.push_back("-fapple-kext");
+ if (Args.hasFlag(options::OPT_frewrite_includes,
+ options::OPT_fno_rewrite_includes, false))
+ CmdArgs.push_back("-frewrite-includes");
+
Args.AddLastArg(CmdArgs, options::OPT_fobjc_sender_dependent_dispatch);
Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_print_source_range_info);
Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_parseable_fixits);
Modified: cfe/branches/tooling/lib/Driver/Tools.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/Tools.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/Tools.h (original)
+++ cfe/branches/tooling/lib/Driver/Tools.h Fri Jun 15 06:08:27 2012
@@ -39,6 +39,7 @@
void AddARMTargetArgs(const ArgList &Args, ArgStringList &CmdArgs,
bool KernelOrKext) const;
void AddMIPSTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
+ void AddPPCTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
void AddSparcTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
void AddX86TargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
void AddHexagonTargetArgs (const ArgList &Args, ArgStringList &CmdArgs) const;
Modified: cfe/branches/tooling/lib/Edit/RewriteObjCFoundationAPI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Edit/RewriteObjCFoundationAPI.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Edit/RewriteObjCFoundationAPI.cpp (original)
+++ cfe/branches/tooling/lib/Edit/RewriteObjCFoundationAPI.cpp Fri Jun 15 06:08:27 2012
@@ -22,7 +22,8 @@
using namespace edit;
static bool checkForLiteralCreation(const ObjCMessageExpr *Msg,
- IdentifierInfo *&ClassId) {
+ IdentifierInfo *&ClassId,
+ const LangOptions &LangOpts) {
if (!Msg || Msg->isImplicit() || !Msg->getMethodDecl())
return false;
@@ -34,6 +35,18 @@
if (Msg->getReceiverKind() == ObjCMessageExpr::Class)
return true;
+ // When in ARC mode we also convert "[[.. alloc] init]" messages to literals,
+ // since the change from +1 to +0 will be handled fine by ARC.
+ if (LangOpts.ObjCAutoRefCount) {
+ if (Msg->getReceiverKind() == ObjCMessageExpr::Instance) {
+ if (const ObjCMessageExpr *Rec = dyn_cast<ObjCMessageExpr>(
+ Msg->getInstanceReceiver()->IgnoreParenImpCasts())) {
+ if (Rec->getMethodFamily() == OMF_alloc)
+ return true;
+ }
+ }
+ }
+
return false;
}
@@ -44,7 +57,7 @@
bool edit::rewriteObjCRedundantCallWithLiteral(const ObjCMessageExpr *Msg,
const NSAPI &NS, Commit &commit) {
IdentifierInfo *II = 0;
- if (!checkForLiteralCreation(Msg, II))
+ if (!checkForLiteralCreation(Msg, II, NS.getASTContext().getLangOpts()))
return false;
if (Msg->getNumArgs() != 1)
return false;
@@ -54,16 +67,19 @@
if ((isa<ObjCStringLiteral>(Arg) &&
NS.getNSClassId(NSAPI::ClassId_NSString) == II &&
- NS.getNSStringSelector(NSAPI::NSStr_stringWithString) == Sel) ||
+ (NS.getNSStringSelector(NSAPI::NSStr_stringWithString) == Sel ||
+ NS.getNSStringSelector(NSAPI::NSStr_initWithString) == Sel)) ||
(isa<ObjCArrayLiteral>(Arg) &&
NS.getNSClassId(NSAPI::ClassId_NSArray) == II &&
- NS.getNSArraySelector(NSAPI::NSArr_arrayWithArray) == Sel) ||
+ (NS.getNSArraySelector(NSAPI::NSArr_arrayWithArray) == Sel ||
+ NS.getNSArraySelector(NSAPI::NSArr_initWithArray) == Sel)) ||
(isa<ObjCDictionaryLiteral>(Arg) &&
NS.getNSClassId(NSAPI::ClassId_NSDictionary) == II &&
- NS.getNSDictionarySelector(
- NSAPI::NSDict_dictionaryWithDictionary) == Sel)) {
+ (NS.getNSDictionarySelector(
+ NSAPI::NSDict_dictionaryWithDictionary) == Sel ||
+ NS.getNSDictionarySelector(NSAPI::NSDict_initWithDictionary) == Sel))) {
commit.replaceWithInner(Msg->getSourceRange(),
Msg->getArg(0)->getSourceRange());
@@ -246,7 +262,7 @@
bool edit::rewriteToObjCLiteralSyntax(const ObjCMessageExpr *Msg,
const NSAPI &NS, Commit &commit) {
IdentifierInfo *II = 0;
- if (!checkForLiteralCreation(Msg, II))
+ if (!checkForLiteralCreation(Msg, II, NS.getASTContext().getLangOpts()))
return false;
if (II == NS.getNSClassId(NSAPI::ClassId_NSArray))
@@ -290,7 +306,8 @@
return true;
}
- if (Sel == NS.getNSArraySelector(NSAPI::NSArr_arrayWithObjects)) {
+ if (Sel == NS.getNSArraySelector(NSAPI::NSArr_arrayWithObjects) ||
+ Sel == NS.getNSArraySelector(NSAPI::NSArr_initWithObjects)) {
if (Msg->getNumArgs() == 0)
return false;
const Expr *SentinelExpr = Msg->getArg(Msg->getNumArgs() - 1);
@@ -352,7 +369,8 @@
}
if (Sel == NS.getNSDictionarySelector(
- NSAPI::NSDict_dictionaryWithObjectsAndKeys)) {
+ NSAPI::NSDict_dictionaryWithObjectsAndKeys) ||
+ Sel == NS.getNSDictionarySelector(NSAPI::NSDict_initWithObjectsAndKeys)) {
if (Msg->getNumArgs() % 2 != 1)
return false;
unsigned SentinelIdx = Msg->getNumArgs() - 1;
Modified: cfe/branches/tooling/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/ASTUnit.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/ASTUnit.cpp Fri Jun 15 06:08:27 2012
@@ -1133,7 +1133,8 @@
StoredDiagnostics);
}
- Act->Execute();
+ if (!Act->Execute())
+ goto error;
transferASTDataFromCompilerInstance(*Clang);
@@ -1795,7 +1796,13 @@
AST->getCurrentTopLevelHashValue()));
Clang->setASTConsumer(new MultiplexConsumer(Consumers));
}
- Act->Execute();
+ if (!Act->Execute()) {
+ AST->transferASTDataFromCompilerInstance(*Clang);
+ if (OwnAST && ErrAST)
+ ErrAST->swap(OwnAST);
+
+ return 0;
+ }
// Steal the created target, context, and preprocessor.
AST->transferASTDataFromCompilerInstance(*Clang);
Modified: cfe/branches/tooling/lib/Frontend/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/CMakeLists.txt?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/CMakeLists.txt (original)
+++ cfe/branches/tooling/lib/Frontend/CMakeLists.txt Fri Jun 15 06:08:27 2012
@@ -41,13 +41,6 @@
Warnings.cpp
)
-IF(MSVC)
- get_target_property(NON_ANSI_COMPILE_FLAGS clangFrontend COMPILE_FLAGS)
- string(REPLACE /Za
- "" NON_ANSI_COMPILE_FLAGS
- ${NON_ANSI_COMPILE_FLAGS})
- set_target_properties(clangFrontend PROPERTIES COMPILE_FLAGS ${NON_ANSI_COMPILE_FLAGS})
-ENDIF(MSVC)
add_dependencies(clangFrontend
ClangAttrClasses
Modified: cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp Fri Jun 15 06:08:27 2012
@@ -623,6 +623,16 @@
Res.push_back(E.Path);
}
+ /// User-specified system header prefixes.
+ for (unsigned i = 0, e = Opts.SystemHeaderPrefixes.size(); i != e; ++i) {
+ if (Opts.SystemHeaderPrefixes[i].IsSystemHeader)
+ Res.push_back("-isystem-prefix");
+ else
+ Res.push_back("-ino-system-prefix");
+
+ Res.push_back(Opts.SystemHeaderPrefixes[i].Prefix);
+ }
+
if (!Opts.ResourceDir.empty())
Res.push_back("-resource-dir", Opts.ResourceDir);
if (!Opts.ModuleCachePath.empty())
@@ -895,7 +905,7 @@
Res.push_back("-target-feature", Opts.Features[i]);
}
-void CompilerInvocation::toArgs(std::vector<std::string> &Res) {
+void CompilerInvocation::toArgs(std::vector<std::string> &Res) const {
ToArgsList List(Res);
AnalyzerOptsToArgs(getAnalyzerOpts(), List);
CodeGenOptsToArgs(getCodeGenOpts(), List);
@@ -1685,6 +1695,14 @@
Opts.AddPath((*I)->getValue(Args), frontend::System,
false, false, /*IgnoreSysRoot=*/true, /*IsInternal=*/true,
(*I)->getOption().matches(OPT_internal_externc_isystem));
+
+ // Add the path prefixes which are implicitly treated as being system headers.
+ for (arg_iterator I = Args.filtered_begin(OPT_isystem_prefix,
+ OPT_ino_system_prefix),
+ E = Args.filtered_end();
+ I != E; ++I)
+ Opts.AddSystemHeaderPrefix((*I)->getValue(Args),
+ (*I)->getOption().matches(OPT_isystem_prefix));
}
void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
@@ -2123,6 +2141,7 @@
Opts.ShowLineMarkers = !Args.hasArg(OPT_P);
Opts.ShowMacroComments = Args.hasArg(OPT_CC);
Opts.ShowMacros = Args.hasArg(OPT_dM) || Args.hasArg(OPT_dD);
+ Opts.RewriteIncludes = Args.hasArg(OPT_frewrite_includes);
}
static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args) {
Modified: cfe/branches/tooling/lib/Frontend/FrontendAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/FrontendAction.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/FrontendAction.cpp Fri Jun 15 06:08:27 2012
@@ -315,7 +315,7 @@
return false;
}
-void FrontendAction::Execute() {
+bool FrontendAction::Execute() {
CompilerInstance &CI = getCompilerInstance();
// Initialize the main file entry. This needs to be delayed until after PCH
@@ -325,7 +325,7 @@
getCurrentInput().IsSystem
? SrcMgr::C_System
: SrcMgr::C_User))
- return;
+ return false;
}
if (CI.hasFrontendTimer()) {
@@ -333,6 +333,8 @@
ExecuteAction();
}
else ExecuteAction();
+
+ return true;
}
void FrontendAction::EndSourceFile() {
Modified: cfe/branches/tooling/lib/Frontend/InitHeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/InitHeaderSearch.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/InitHeaderSearch.cpp Fri Jun 15 06:08:27 2012
@@ -40,6 +40,7 @@
std::vector<std::pair<IncludeDirGroup, DirectoryLookup> > IncludePath;
typedef std::vector<std::pair<IncludeDirGroup,
DirectoryLookup> >::const_iterator path_iterator;
+ std::vector<std::pair<std::string, bool> > SystemHeaderPrefixes;
HeaderSearch &Headers;
bool Verbose;
std::string IncludeSysroot;
@@ -57,6 +58,12 @@
bool isCXXAware, bool isUserSupplied,
bool isFramework, bool IgnoreSysRoot = false);
+ /// AddSystemHeaderPrefix - Add the specified prefix to the system header
+ /// prefix list.
+ void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
+ SystemHeaderPrefixes.push_back(std::make_pair(Prefix, IsSystemHeader));
+ }
+
/// AddGnuCPlusPlusIncludePaths - Add the necessary paths to support a gnu
/// libstdc++.
void AddGnuCPlusPlusIncludePaths(StringRef Base,
@@ -623,6 +630,8 @@
bool DontSearchCurDir = false; // TODO: set to true if -I- is set?
Headers.SetSearchPaths(SearchList, NumQuoted, NumAngled, DontSearchCurDir);
+ Headers.SetSystemHeaderPrefixes(SystemHeaderPrefixes);
+
// If verbose, print the list of directories that will be searched.
if (Verbose) {
llvm::errs() << "#include \"...\" search starts here:\n";
@@ -660,6 +669,10 @@
Init.AddDefaultIncludePaths(Lang, Triple, HSOpts);
+ for (unsigned i = 0, e = HSOpts.SystemHeaderPrefixes.size(); i != e; ++i)
+ Init.AddSystemHeaderPrefix(HSOpts.SystemHeaderPrefixes[i].Prefix,
+ HSOpts.SystemHeaderPrefixes[i].IsSystemHeader);
+
if (HSOpts.UseBuiltinIncludes) {
// Set up the builtin include directory in the module map.
llvm::sys::Path P(HSOpts.ResourceDir);
Modified: cfe/branches/tooling/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/InitPreprocessor.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/InitPreprocessor.cpp Fri Jun 15 06:08:27 2012
@@ -49,7 +49,7 @@
}
}
-/// AddImplicitInclude - Add an implicit #include of the specified file to the
+/// AddImplicitInclude - Add an implicit \#include of the specified file to the
/// predefines buffer.
static void AddImplicitInclude(MacroBuilder &Builder, StringRef File,
FileManager &FileMgr) {
@@ -66,8 +66,8 @@
Builder.append("##"); // ##?
}
-/// AddImplicitIncludePTH - Add an implicit #include using the original file
-/// used to generate a PTH cache.
+/// AddImplicitIncludePTH - Add an implicit \#include using the original file
+/// used to generate a PTH cache.
static void AddImplicitIncludePTH(MacroBuilder &Builder, Preprocessor &PP,
StringRef ImplicitIncludePTH) {
PTHManager *P = PP.getPTHManager();
Modified: cfe/branches/tooling/lib/Frontend/LayoutOverrideSource.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/LayoutOverrideSource.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/LayoutOverrideSource.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/LayoutOverrideSource.cpp Fri Jun 15 06:08:27 2012
@@ -174,7 +174,7 @@
if (NumFields >= Known->second.FieldOffsets.size())
continue;
- FieldOffsets[&*F] = Known->second.FieldOffsets[NumFields];
+ FieldOffsets[*F] = Known->second.FieldOffsets[NumFields];
}
// Wrong number of fields.
Modified: cfe/branches/tooling/lib/Frontend/TextDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/TextDiagnostic.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/TextDiagnostic.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/TextDiagnostic.cpp Fri Jun 15 06:08:27 2012
@@ -1090,6 +1090,7 @@
std::string FixItInsertionLine;
if (Hints.empty() || !DiagOpts.ShowFixits)
return FixItInsertionLine;
+ unsigned PrevHintEnd = 0;
for (ArrayRef<FixItHint>::iterator I = Hints.begin(), E = Hints.end();
I != E; ++I) {
@@ -1107,6 +1108,16 @@
assert(HintColNo<static_cast<unsigned>(map.bytes())+1);
HintColNo = map.byteToColumn(HintColNo);
+ // If we inserted a long previous hint, push this one forwards, and add
+ // an extra space to show that this is not part of the previous
+ // completion. This is sort of the best we can do when two hints appear
+ // to overlap.
+ //
+ // Note that if this hint is located immediately after the previous
+ // hint, no space will be added, since the location is more important.
+ if (HintColNo < PrevHintEnd)
+ HintColNo = PrevHintEnd + 1;
+
// FIXME: if the fixit includes tabs or other characters that do not
// take up a single column per byte when displayed then
// I->CodeToInsert.size() is not a column number and we're mixing
@@ -1115,19 +1126,16 @@
unsigned LastColumnModified
= HintColNo + I->CodeToInsert.size();
- if (LastColumnModified > static_cast<unsigned>(map.bytes())) {
- unsigned LastExistingColumn = map.byteToColumn(map.bytes());
- unsigned AddedColumns = LastColumnModified-LastExistingColumn;
- LastColumnModified = LastExistingColumn + AddedColumns;
- } else {
+ if (LastColumnModified <= static_cast<unsigned>(map.bytes()))
LastColumnModified = map.byteToColumn(LastColumnModified);
- }
if (LastColumnModified > FixItInsertionLine.size())
FixItInsertionLine.resize(LastColumnModified, ' ');
assert(HintColNo+I->CodeToInsert.size() <= FixItInsertionLine.size());
std::copy(I->CodeToInsert.begin(), I->CodeToInsert.end(),
FixItInsertionLine.begin() + HintColNo);
+
+ PrevHintEnd = LastColumnModified;
} else {
FixItInsertionLine.clear();
break;
Modified: cfe/branches/tooling/lib/FrontendTool/ExecuteCompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/FrontendTool/ExecuteCompilerInvocation.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/FrontendTool/ExecuteCompilerInvocation.cpp (original)
+++ cfe/branches/tooling/lib/FrontendTool/ExecuteCompilerInvocation.cpp Fri Jun 15 06:08:27 2012
@@ -71,7 +71,12 @@
case PrintDeclContext: return new DeclContextPrintAction();
case PrintPreamble: return new PrintPreambleAction();
- case PrintPreprocessedInput: return new PrintPreprocessedAction();
+ case PrintPreprocessedInput: {
+ if (CI.getPreprocessorOutputOpts().RewriteIncludes)
+ return new RewriteIncludesAction();
+ return new PrintPreprocessedAction();
+ }
+
case RewriteMacros: return new RewriteMacrosAction();
case RewriteObjC: return new RewriteObjCAction();
case RewriteTest: return new RewriteTestAction();
Modified: cfe/branches/tooling/lib/Headers/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Headers/CMakeLists.txt?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Headers/CMakeLists.txt (original)
+++ cfe/branches/tooling/lib/Headers/CMakeLists.txt Fri Jun 15 06:08:27 2012
@@ -31,6 +31,7 @@
wmmintrin.h
x86intrin.h
xmmintrin.h
+ xopintrin.h
cpuid.h
unwind.h
module.map
Modified: cfe/branches/tooling/lib/Headers/x86intrin.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Headers/x86intrin.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Headers/x86intrin.h (original)
+++ cfe/branches/tooling/lib/Headers/x86intrin.h Fri Jun 15 06:08:27 2012
@@ -54,6 +54,10 @@
#include <fma4intrin.h>
#endif
-// FIXME: XOP, LWP
+#ifdef __XOP__
+#include <xopintrin.h>
+#endif
+
+// FIXME: LWP
#endif /* __X86INTRIN_H */
Modified: cfe/branches/tooling/lib/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/HeaderSearch.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/branches/tooling/lib/Lex/HeaderSearch.cpp Fri Jun 15 06:08:27 2012
@@ -510,6 +510,16 @@
if (HFI.DirInfo == SrcMgr::C_User && InUserSpecifiedSystemFramework)
HFI.DirInfo = SrcMgr::C_System;
+ // If the filename matches a known system header prefix, override
+ // whether the file is a system header.
+ for (unsigned j = SystemHeaderPrefixes.size(); j; --j) {
+ if (Filename.startswith(SystemHeaderPrefixes[j-1].first)) {
+ HFI.DirInfo = SystemHeaderPrefixes[j-1].second ? SrcMgr::C_System
+ : SrcMgr::C_User;
+ break;
+ }
+ }
+
// If this file is found in a header map and uses the framework style of
// includes, then this header is part of a framework we're building.
if (CurDir->isIndexHeaderMap()) {
Modified: cfe/branches/tooling/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/Lexer.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/Lexer.cpp (original)
+++ cfe/branches/tooling/lib/Lex/Lexer.cpp Fri Jun 15 06:08:27 2012
@@ -127,7 +127,7 @@
}
/// Lexer constructor - Create a new raw lexer object. This object is only
-/// suitable for calls to 'LexRawToken'. This lexer assumes that the text
+/// suitable for calls to 'LexFromRawLexer'. This lexer assumes that the text
/// range will outlive it, so it doesn't take ownership of it.
Lexer::Lexer(SourceLocation fileloc, const LangOptions &langOpts,
const char *BufStart, const char *BufPtr, const char *BufEnd)
@@ -140,7 +140,7 @@
}
/// Lexer constructor - Create a new raw lexer object. This object is only
-/// suitable for calls to 'LexRawToken'. This lexer assumes that the text
+/// suitable for calls to 'LexFromRawLexer'. This lexer assumes that the text
/// range will outlive it, so it doesn't take ownership of it.
Lexer::Lexer(FileID FID, const llvm::MemoryBuffer *FromFile,
const SourceManager &SM, const LangOptions &langOpts)
@@ -1124,6 +1124,11 @@
true : false;
}
+// Allow external clients to make use of CharInfo.
+bool Lexer::isIdentifierBodyChar(char c, const LangOptions &LangOpts) {
+ return isIdentifierBody(c) || (c == '$' && LangOpts.DollarIdents);
+}
+
//===----------------------------------------------------------------------===//
// Diagnostics forwarding code.
@@ -1564,8 +1569,20 @@
}
// If we have a hex FP constant, continue.
- if ((C == '-' || C == '+') && (PrevCh == 'P' || PrevCh == 'p'))
- return LexNumericConstant(Result, ConsumeChar(CurPtr, Size, Result));
+ if ((C == '-' || C == '+') && (PrevCh == 'P' || PrevCh == 'p')) {
+ // Outside C99, we accept hexadecimal floating point numbers as a
+ // not-quite-conforming extension. Only do so if this looks like it's
+ // actually meant to be a hexfloat, and not if it has a ud-suffix.
+ bool IsHexFloat = true;
+ if (!LangOpts.C99) {
+ if (!isHexaLiteral(BufferPtr, LangOpts))
+ IsHexFloat = false;
+ else if (std::find(BufferPtr, CurPtr, '_') != CurPtr)
+ IsHexFloat = false;
+ }
+ if (IsHexFloat)
+ return LexNumericConstant(Result, ConsumeChar(CurPtr, Size, Result));
+ }
// Update the location of token as well as BufferPtr.
const char *TokStart = BufferPtr;
@@ -2022,7 +2039,7 @@
// directly.
FormTokenWithChars(Result, CurPtr, tok::comment);
- if (!ParsingPreprocessorDirective)
+ if (!ParsingPreprocessorDirective || LexingRawMode)
return true;
// If this BCPL-style comment is in a macro definition, transmogrify it into
@@ -2043,8 +2060,8 @@
}
/// isBlockCommentEndOfEscapedNewLine - Return true if the specified newline
-/// character (either \n or \r) is part of an escaped newline sequence. Issue a
-/// diagnostic if so. We know that the newline is inside of a block comment.
+/// character (either \\n or \\r) is part of an escaped newline sequence. Issue
+/// a diagnostic if so. We know that the newline is inside of a block comment.
static bool isEndOfBlockCommentWithEscapedNewLine(const char *CurPtr,
Lexer *L) {
assert(CurPtr[0] == '\n' || CurPtr[0] == '\r');
@@ -2626,7 +2643,8 @@
ParsingPreprocessorDirective = false;
// Restore comment saving mode, in case it was disabled for directive.
- SetCommentRetentionState(PP->getCommentRetentionState());
+ if (PP)
+ SetCommentRetentionState(PP->getCommentRetentionState());
// Since we consumed a newline, we are back at the start of a line.
IsAtStartOfLine = true;
Modified: cfe/branches/tooling/lib/Lex/LiteralSupport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/LiteralSupport.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/branches/tooling/lib/Lex/LiteralSupport.cpp Fri Jun 15 06:08:27 2012
@@ -250,6 +250,39 @@
return true;
}
+/// MeasureUCNEscape - Determine the number of bytes within the resulting string
+/// which this UCN will occupy.
+static int MeasureUCNEscape(const char *ThisTokBegin, const char *&ThisTokBuf,
+ const char *ThisTokEnd, unsigned CharByteWidth,
+ const LangOptions &Features, bool &HadError) {
+ // UTF-32: 4 bytes per escape.
+ if (CharByteWidth == 4)
+ return 4;
+
+ uint32_t UcnVal = 0;
+ unsigned short UcnLen = 0;
+ FullSourceLoc Loc;
+
+ if (!ProcessUCNEscape(ThisTokBegin, ThisTokBuf, ThisTokEnd, UcnVal,
+ UcnLen, Loc, 0, Features, true)) {
+ HadError = true;
+ return 0;
+ }
+
+ // UTF-16: 2 bytes for BMP, 4 bytes otherwise.
+ if (CharByteWidth == 2)
+ return UcnVal <= 0xFFFF ? 2 : 4;
+
+ // UTF-8.
+ if (UcnVal < 0x80)
+ return 1;
+ if (UcnVal < 0x800)
+ return 2;
+ if (UcnVal < 0x10000)
+ return 3;
+ return 4;
+}
+
/// EncodeUCNEscape - Read the Universal Character Name, check constraints and
/// convert the UTF32 to UTF8 or UTF16. This is a subroutine of
/// StringLiteralParser. When we decide to implement UCN's for identifiers,
@@ -265,7 +298,7 @@
unsigned short UcnLen = 0;
if (!ProcessUCNEscape(ThisTokBegin, ThisTokBuf, ThisTokEnd, UcnVal, UcnLen,
Loc, Diags, Features, true)) {
- HadError = 1;
+ HadError = true;
return;
}
@@ -289,7 +322,7 @@
// using reinterpret_cast.
UTF16 *ResultPtr = reinterpret_cast<UTF16*>(ResultBuf);
- if (UcnVal < (UTF32)0xFFFF) {
+ if (UcnVal <= (UTF32)0xFFFF) {
*ResultPtr = UcnVal;
ResultBuf += 2;
return;
@@ -1369,14 +1402,31 @@
if (StringInvalid)
return 0;
+ const char *SpellingStart = SpellingPtr;
+ const char *SpellingEnd = SpellingPtr+TokLen;
+
+ // Handle UTF-8 strings just like narrow strings.
+ if (SpellingPtr[0] == 'u' && SpellingPtr[1] == '8')
+ SpellingPtr += 2;
+
assert(SpellingPtr[0] != 'L' && SpellingPtr[0] != 'u' &&
SpellingPtr[0] != 'U' && "Doesn't handle wide or utf strings yet");
+ // For raw string literals, this is easy.
+ if (SpellingPtr[0] == 'R') {
+ assert(SpellingPtr[1] == '"' && "Should be a raw string literal!");
+ // Skip 'R"'.
+ SpellingPtr += 2;
+ while (*SpellingPtr != '(') {
+ ++SpellingPtr;
+ assert(SpellingPtr < SpellingEnd && "Missing ( for raw string literal");
+ }
+ // Skip '('.
+ ++SpellingPtr;
+ return SpellingPtr - SpellingStart + ByteNo;
+ }
- const char *SpellingStart = SpellingPtr;
- const char *SpellingEnd = SpellingPtr+TokLen;
-
- // Skip over the leading quote.
+ // Skip over the leading quote
assert(SpellingPtr[0] == '"' && "Should be a string literal!");
++SpellingPtr;
@@ -1393,11 +1443,23 @@
// Otherwise, this is an escape character. Advance over it.
bool HadError = false;
- ProcessCharEscape(SpellingPtr, SpellingEnd, HadError,
- FullSourceLoc(Tok.getLocation(), SM),
- CharByteWidth*8, Diags);
+ if (SpellingPtr[1] == 'u' || SpellingPtr[1] == 'U') {
+ const char *EscapePtr = SpellingPtr;
+ unsigned Len = MeasureUCNEscape(SpellingStart, SpellingPtr, SpellingEnd,
+ 1, Features, HadError);
+ if (Len > ByteNo) {
+ // ByteNo is somewhere within the escape sequence.
+ SpellingPtr = EscapePtr;
+ break;
+ }
+ ByteNo -= Len;
+ } else {
+ ProcessCharEscape(SpellingPtr, SpellingEnd, HadError,
+ FullSourceLoc(Tok.getLocation(), SM),
+ CharByteWidth*8, Diags);
+ --ByteNo;
+ }
assert(!HadError && "This method isn't valid on erroneous strings");
- --ByteNo;
}
return SpellingPtr-SpellingStart;
Modified: cfe/branches/tooling/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/PPDirectives.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/PPDirectives.cpp (original)
+++ cfe/branches/tooling/lib/Lex/PPDirectives.cpp Fri Jun 15 06:08:27 2012
@@ -553,6 +553,21 @@
// Preprocessor Directive Handling.
//===----------------------------------------------------------------------===//
+class Preprocessor::ResetMacroExpansionHelper {
+public:
+ ResetMacroExpansionHelper(Preprocessor *pp)
+ : PP(pp), save(pp->DisableMacroExpansion) {
+ if (pp->MacroExpansionInDirectivesOverride)
+ pp->DisableMacroExpansion = false;
+ }
+ ~ResetMacroExpansionHelper() {
+ PP->DisableMacroExpansion = save;
+ }
+private:
+ Preprocessor *PP;
+ bool save;
+};
+
/// HandleDirective - This callback is invoked when the lexer sees a # token
/// at the start of a line. This consumes the directive, modifies the
/// lexer/preprocessor state, and advances the lexer(s) so that the next token
@@ -604,6 +619,10 @@
Diag(Result, diag::ext_embedded_directive);
}
+ // Temporarily enable macro expansion if set so
+ // and reset to previous state when returning from this function.
+ ResetMacroExpansionHelper helper(this);
+
TryAgain:
switch (Result.getKind()) {
case tok::eod:
Modified: cfe/branches/tooling/lib/Lex/Pragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/Pragma.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/Pragma.cpp (original)
+++ cfe/branches/tooling/lib/Lex/Pragma.cpp Fri Jun 15 06:08:27 2012
@@ -103,6 +103,9 @@
/// HandlePragmaDirective - The "#pragma" directive has been parsed. Lex the
/// rest of the pragma, passing it to the registered pragma handlers.
void Preprocessor::HandlePragmaDirective(unsigned Introducer) {
+ if (!PragmasEnabled)
+ return;
+
++NumPragma;
// Invoke the first level of pragma handlers which reads the namespace id.
Modified: cfe/branches/tooling/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/Preprocessor.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/Preprocessor.cpp (original)
+++ cfe/branches/tooling/lib/Lex/Preprocessor.cpp Fri Jun 15 06:08:27 2012
@@ -86,10 +86,12 @@
// Macro expansion is enabled.
DisableMacroExpansion = false;
+ MacroExpansionInDirectivesOverride = false;
InMacroArgs = false;
InMacroArgPreExpansion = false;
NumCachedTokenLexers = 0;
-
+ PragmasEnabled = true;
+
CachedLexPos = 0;
// We haven't read anything from the external source.
@@ -425,7 +427,7 @@
llvm::MemoryBuffer *SB =
llvm::MemoryBuffer::getMemBufferCopy(Predefines, "<built-in>");
assert(SB && "Cannot create predefined source buffer");
- FileID FID = SourceMgr.createFileIDForMemBuffer(SB);
+ FileID FID = SourceMgr.createPredefinesFileIDForMemBuffer(SB);
assert(!FID.isInvalid() && "Could not create FileID for predefines?");
// Start parsing the predefines.
Modified: cfe/branches/tooling/lib/Lex/TokenLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/TokenLexer.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/TokenLexer.cpp (original)
+++ cfe/branches/tooling/lib/Lex/TokenLexer.cpp Fri Jun 15 06:08:27 2012
@@ -568,8 +568,8 @@
<< Buffer.str();
}
- // Do not consume the RHS.
- --CurToken;
+ // An error has occurred so exit loop.
+ break;
}
// Turn ## into 'unknown' to avoid # ## # from looking like a paste
Modified: cfe/branches/tooling/lib/Parse/ParseAST.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseAST.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseAST.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseAST.cpp Fri Jun 15 06:08:27 2012
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Parse/ParseAST.h"
+#include "clang/Parse/ParseDiagnostic.h"
#include "clang/Sema/Sema.h"
#include "clang/Sema/CodeCompleteConsumer.h"
#include "clang/Sema/SemaConsumer.h"
@@ -77,27 +78,50 @@
S.getPreprocessor().EnterMainSourceFile();
P.Initialize();
S.Initialize();
-
- if (ExternalASTSource *External = S.getASTContext().getExternalSource())
+
+ // C11 6.9p1 says translation units must have at least one top-level
+ // declaration. C++ doesn't have this restriction. We also don't want to
+ // complain if we have a precompiled header, although technically if the PCH
+ // is empty we should still emit the (pedantic) diagnostic.
+ bool WarnForEmptyTU = !S.getLangOpts().CPlusPlus;
+ if (ExternalASTSource *External = S.getASTContext().getExternalSource()) {
External->StartTranslationUnit(Consumer);
-
- bool Abort = false;
+ WarnForEmptyTU = false;
+ }
+
+ // Clang's predefines contain top-level declarations for things like va_list,
+ // making it hard to tell if the /user's/ translation unit has at least one
+ // top-level declaration. So we parse cautiously, looking for a declaration
+ // that doesn't come from our predefines.
+ // Note that ParseTopLevelDecl returns 'true' at EOF.
+ SourceManager &SM = S.getSourceManager();
Parser::DeclGroupPtrTy ADecl;
-
- while (!P.ParseTopLevelDecl(ADecl)) { // Not end of file.
- // If we got a null return and something *was* parsed, ignore it. This
- // is due to a top-level semicolon, an action override, or a parse error
- // skipping something.
+ while (WarnForEmptyTU && !P.ParseTopLevelDecl(ADecl)) {
if (ADecl) {
- if (!Consumer->HandleTopLevelDecl(ADecl.get())) {
- Abort = true;
- break;
+ if (!Consumer->HandleTopLevelDecl(ADecl.get()))
+ return;
+ if (DeclGroupRef::iterator FirstDecl = ADecl.get().begin()) {
+ SourceLocation DeclLoc = (*FirstDecl)->getLocation();
+ WarnForEmptyTU = SM.isFromPredefines(DeclLoc);
}
}
- };
+ }
- if (Abort)
- return;
+ // If we ended up seeing EOF before any top-level declarations, emit our
+ // diagnostic. Otherwise, parse the rest of the file normally.
+ if (WarnForEmptyTU) {
+ P.Diag(diag::ext_empty_translation_unit);
+ } else {
+ while (!P.ParseTopLevelDecl(ADecl)) { // Not end of file.
+ // If we got a null return and something *was* parsed, ignore it. This
+ // is due to a top-level semicolon, an action override, or a parse error
+ // skipping something.
+ if (ADecl) {
+ if (!Consumer->HandleTopLevelDecl(ADecl.get()))
+ return;
+ }
+ };
+ }
// Process any TopLevelDecls generated by #pragma weak.
for (SmallVector<Decl*,2>::iterator
Modified: cfe/branches/tooling/lib/Parse/ParseCXXInlineMethods.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseCXXInlineMethods.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseCXXInlineMethods.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseCXXInlineMethods.cpp Fri Jun 15 06:08:27 2012
@@ -46,7 +46,7 @@
else {
FnD = Actions.ActOnCXXMemberDeclarator(getCurScope(), AS, D,
move(TemplateParams), 0,
- VS, /*HasDeferredInit=*/false);
+ VS, ICIS_NoInit);
if (FnD) {
Actions.ProcessDeclAttributeList(getCurScope(), FnD, AccessAttrs,
false, true);
@@ -493,7 +493,7 @@
ConsumeAnyToken();
SourceLocation EqualLoc;
-
+
ExprResult Init = ParseCXXMemberInitializer(MI.Field, /*IsFunction=*/false,
EqualLoc);
Modified: cfe/branches/tooling/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseDecl.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseDecl.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseDecl.cpp Fri Jun 15 06:08:27 2012
@@ -4276,7 +4276,7 @@
SmallVector<SourceRange, 2> DynamicExceptionRanges;
ExprResult NoexceptExpr;
ParsedAttributes FnAttrs(AttrFactory);
- ParsedType TrailingReturnType;
+ TypeResult TrailingReturnType;
Actions.ActOnStartFunctionDeclarator();
@@ -4358,7 +4358,7 @@
if (getLangOpts().CPlusPlus0x && Tok.is(tok::arrow)) {
Diag(Tok, diag::warn_cxx98_compat_trailing_return_type);
SourceRange Range;
- TrailingReturnType = ParseTrailingReturnType(Range).get();
+ TrailingReturnType = ParseTrailingReturnType(Range);
if (Range.getEnd().isValid())
EndLoc = Range.getEnd();
}
Modified: cfe/branches/tooling/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseDeclCXX.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseDeclCXX.cpp Fri Jun 15 06:08:27 2012
@@ -1991,18 +1991,19 @@
// goes before or after the GNU attributes and __asm__.
ParseOptionalCXX0XVirtSpecifierSeq(VS);
- bool HasDeferredInitializer = false;
+ InClassInitStyle HasInClassInit = ICIS_NoInit;
if ((Tok.is(tok::equal) || Tok.is(tok::l_brace)) && !HasInitializer) {
if (BitfieldSize.get()) {
Diag(Tok, diag::err_bitfield_member_init);
SkipUntil(tok::comma, true, true);
} else {
HasInitializer = true;
- HasDeferredInitializer = !DeclaratorInfo.isDeclarationOfFunction() &&
- DeclaratorInfo.getDeclSpec().getStorageClassSpec()
- != DeclSpec::SCS_static &&
- DeclaratorInfo.getDeclSpec().getStorageClassSpec()
- != DeclSpec::SCS_typedef;
+ if (!DeclaratorInfo.isDeclarationOfFunction() &&
+ DeclaratorInfo.getDeclSpec().getStorageClassSpec()
+ != DeclSpec::SCS_static &&
+ DeclaratorInfo.getDeclSpec().getStorageClassSpec()
+ != DeclSpec::SCS_typedef)
+ HasInClassInit = Tok.is(tok::equal) ? ICIS_CopyInit : ICIS_ListInit;
}
}
@@ -2020,7 +2021,7 @@
DeclaratorInfo,
move(TemplateParams),
BitfieldSize.release(),
- VS, HasDeferredInitializer);
+ VS, HasInClassInit);
if (AccessAttrs)
Actions.ProcessDeclAttributeList(getCurScope(), ThisDecl, AccessAttrs,
false, true);
@@ -2036,15 +2037,15 @@
LateParsedAttrs.clear();
// Handle the initializer.
- if (HasDeferredInitializer) {
+ if (HasInClassInit != ICIS_NoInit) {
// The initializer was deferred; parse it and cache the tokens.
Diag(Tok, getLangOpts().CPlusPlus0x ?
diag::warn_cxx98_compat_nonstatic_member_init :
diag::ext_nonstatic_member_init);
if (DeclaratorInfo.isArrayOfUnknownBound()) {
- // C++0x [dcl.array]p3: An array bound may also be omitted when the
- // declarator is followed by an initializer.
+ // C++11 [dcl.array]p3: An array bound may also be omitted when the
+ // declarator is followed by an initializer.
//
// A brace-or-equal-initializer for a member-declarator is not an
// initializer in the grammar, so this is ill-formed.
Modified: cfe/branches/tooling/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseExpr.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseExpr.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseExpr.cpp Fri Jun 15 06:08:27 2012
@@ -182,8 +182,8 @@
/// This routine is called when the '@' is seen and consumed.
/// Current token is an Identifier and is not a 'try'. This
-/// routine is necessary to disambiguate @try-statement from,
-/// for example, @encode-expression.
+/// routine is necessary to disambiguate \@try-statement from,
+/// for example, \@encode-expression.
///
ExprResult
Parser::ParseExpressionWithLeadingAt(SourceLocation AtLoc) {
@@ -531,9 +531,9 @@
/// [GNU] '__builtin_types_compatible_p' '(' type-name ',' type-name ')'
/// [GNU] '__null'
/// [OBJC] '[' objc-message-expr ']'
-/// [OBJC] '@selector' '(' objc-selector-arg ')'
-/// [OBJC] '@protocol' '(' identifier ')'
-/// [OBJC] '@encode' '(' type-name ')'
+/// [OBJC] '\@selector' '(' objc-selector-arg ')'
+/// [OBJC] '\@protocol' '(' identifier ')'
+/// [OBJC] '\@encode' '(' type-name ')'
/// [OBJC] objc-string-literal
/// [C++] simple-type-specifier '(' expression-list[opt] ')' [C++ 5.2.3]
/// [C++11] simple-type-specifier braced-init-list [C++11 5.2.3]
@@ -1888,7 +1888,6 @@
bool isTypeCast, ParsedType &CastTy,
SourceLocation &RParenLoc) {
assert(Tok.is(tok::l_paren) && "Not a paren expr!");
- GreaterThanIsOperatorScope G(GreaterThanIsOperator, true);
BalancedDelimiterTracker T(*this, tok::l_paren);
if (T.consumeOpen())
return ExprError();
Modified: cfe/branches/tooling/lib/Parse/ParseExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseExprCXX.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseExprCXX.cpp Fri Jun 15 06:08:27 2012
@@ -792,10 +792,10 @@
MaybeParseCXX0XAttributes(Attr, &DeclEndLoc);
// Parse trailing-return-type[opt].
- ParsedType TrailingReturnType;
+ TypeResult TrailingReturnType;
if (Tok.is(tok::arrow)) {
SourceRange Range;
- TrailingReturnType = ParseTrailingReturnType(Range).get();
+ TrailingReturnType = ParseTrailingReturnType(Range);
if (Range.getEnd().isValid())
DeclEndLoc = Range.getEnd();
}
@@ -838,10 +838,10 @@
}
// Parse the return type, if there is one.
- ParsedType TrailingReturnType;
+ TypeResult TrailingReturnType;
if (Tok.is(tok::arrow)) {
SourceRange Range;
- TrailingReturnType = ParseTrailingReturnType(Range).get();
+ TrailingReturnType = ParseTrailingReturnType(Range);
if (Range.getEnd().isValid())
DeclEndLoc = Range.getEnd();
}
@@ -1235,8 +1235,6 @@
MultiExprArg(&InitList, 1),
SourceLocation());
} else {
- GreaterThanIsOperatorScope G(GreaterThanIsOperator, true);
-
BalancedDelimiterTracker T(*this, tok::l_paren);
T.consumeOpen();
Modified: cfe/branches/tooling/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseObjc.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseObjc.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseObjc.cpp Fri Jun 15 06:08:27 2012
@@ -1347,15 +1347,15 @@
/// objc-protocol-forward-reference
///
/// objc-protocol-definition:
-/// @protocol identifier
+/// \@protocol identifier
/// objc-protocol-refs[opt]
/// objc-interface-decl-list
-/// @end
+/// \@end
///
/// objc-protocol-forward-reference:
-/// @protocol identifier-list ';'
+/// \@protocol identifier-list ';'
///
-/// "@protocol identifier ;" should be resolved as "@protocol
+/// "\@protocol identifier ;" should be resolved as "\@protocol
/// identifier-list ;": objc-interface-decl-list may not start with a
/// semicolon in the first alternative if objc-protocol-refs are omitted.
Parser::DeclGroupPtrTy
@@ -2730,7 +2730,7 @@
}
/// objc-protocol-expression
-/// @protocol ( protocol-name )
+/// \@protocol ( protocol-name )
ExprResult
Parser::ParseObjCProtocolExpression(SourceLocation AtLoc) {
SourceLocation ProtoLoc = ConsumeToken();
Modified: cfe/branches/tooling/lib/Parse/ParsePragma.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParsePragma.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParsePragma.h (original)
+++ cfe/branches/tooling/lib/Parse/ParsePragma.h Fri Jun 15 06:08:27 2012
@@ -30,10 +30,9 @@
};
class PragmaGCCVisibilityHandler : public PragmaHandler {
- Sema &Actions;
public:
- explicit PragmaGCCVisibilityHandler(Sema &A) : PragmaHandler("visibility"),
- Actions(A) {}
+ explicit PragmaGCCVisibilityHandler(Sema &/*A*/)
+ : PragmaHandler("visibility") {}
virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
Token &FirstToken);
@@ -70,11 +69,9 @@
};
class PragmaUnusedHandler : public PragmaHandler {
- Sema &Actions;
- Parser &parser;
public:
- PragmaUnusedHandler(Sema &A, Parser& p)
- : PragmaHandler("unused"), Actions(A), parser(p) {}
+ PragmaUnusedHandler(Sema &/*A*/)
+ : PragmaHandler("unused") {}
virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
Token &FirstToken);
@@ -102,10 +99,9 @@
class PragmaOpenCLExtensionHandler : public PragmaHandler {
Sema &Actions;
- Parser &parser;
public:
- PragmaOpenCLExtensionHandler(Sema &S, Parser& p) :
- PragmaHandler("EXTENSION"), Actions(S), parser(p) {}
+ PragmaOpenCLExtensionHandler(Sema &A) :
+ PragmaHandler("EXTENSION"), Actions(A) {}
virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
Token &FirstToken);
};
@@ -113,10 +109,9 @@
class PragmaFPContractHandler : public PragmaHandler {
Sema &Actions;
- Parser &parser;
public:
- PragmaFPContractHandler(Sema &S, Parser& p) :
- PragmaHandler("FP_CONTRACT"), Actions(S), parser(p) {}
+ PragmaFPContractHandler(Sema &A) :
+ PragmaHandler("FP_CONTRACT"), Actions(A) {}
virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
Token &FirstToken);
};
Modified: cfe/branches/tooling/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseStmt.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseStmt.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseStmt.cpp Fri Jun 15 06:08:27 2012
@@ -20,6 +20,7 @@
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/PrettyStackTrace.h"
#include "clang/Basic/SourceManager.h"
+#include "llvm/ADT/SmallString.h"
using namespace clang;
//===----------------------------------------------------------------------===//
@@ -1625,11 +1626,61 @@
return Actions.ActOnReturnStmt(ReturnLoc, R.take());
}
+// needSpaceAsmToken - This function handles whitespace around asm punctuation.
+// Returns true if a space should be emitted.
+static inline bool needSpaceAsmToken(Token currTok) {
+ static Token prevTok;
+
+ // No need for space after prevToken.
+ switch(prevTok.getKind()) {
+ default:
+ break;
+ case tok::l_square:
+ case tok::r_square:
+ case tok::l_brace:
+ case tok::r_brace:
+ case tok::colon:
+ prevTok = currTok;
+ return false;
+ }
+
+ // No need for a space before currToken.
+ switch(currTok.getKind()) {
+ default:
+ break;
+ case tok::l_square:
+ case tok::r_square:
+ case tok::l_brace:
+ case tok::r_brace:
+ case tok::comma:
+ case tok::colon:
+ prevTok = currTok;
+ return false;
+ }
+ prevTok = currTok;
+ return true;
+}
+
/// ParseMicrosoftAsmStatement. When -fms-extensions/-fasm-blocks is enabled,
/// this routine is called to collect the tokens for an MS asm statement.
+///
+/// [MS] ms-asm-statement:
+/// ms-asm-block
+/// ms-asm-block ms-asm-statement
+///
+/// [MS] ms-asm-block:
+/// '__asm' ms-asm-line '\n'
+/// '__asm' '{' ms-asm-instruction-block[opt] '}' ';'[opt]
+///
+/// [MS] ms-asm-instruction-block
+/// ms-asm-line
+/// ms-asm-line '\n' ms-asm-instruction-block
+///
StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
SourceManager &SrcMgr = PP.getSourceManager();
SourceLocation EndLoc = AsmLoc;
+ SmallVector<Token, 4> AsmToks;
+ SmallVector<unsigned, 4> LineEnds;
do {
bool InBraces = false;
unsigned short savedBraceCount = 0;
@@ -1658,8 +1709,10 @@
// If we hit EOF, we're done, period.
if (Tok.is(tok::eof))
break;
- // When we consume the closing brace, we're done.
- if (InBraces && BraceCount == savedBraceCount)
+
+ // The asm keyword is a statement separator, so multiple asm statements
+ // are allowed.
+ if (!InAsmComment && Tok.is(tok::kw_asm))
break;
if (!InAsmComment && Tok.is(tok::semi)) {
@@ -1691,18 +1744,28 @@
break;
}
}
+ if (!InAsmComment && InBraces && Tok.is(tok::r_brace) &&
+ BraceCount == (savedBraceCount + 1)) {
+ // Consume the closing brace, and finish
+ EndLoc = ConsumeBrace();
+ break;
+ }
// Consume the next token; make sure we don't modify the brace count etc.
// if we are in a comment.
EndLoc = TokLoc;
if (InAsmComment)
PP.Lex(Tok);
- else
+ else {
+ AsmToks.push_back(Tok);
ConsumeAnyToken();
+ }
TokLoc = Tok.getLocation();
++NumTokensRead;
} while (1);
+ LineEnds.push_back(AsmToks.size());
+
if (InBraces && BraceCount != savedBraceCount) {
// __asm without closing brace (this can happen at EOF).
Diag(Tok, diag::err_expected_rbrace);
@@ -1719,24 +1782,34 @@
break;
EndLoc = ConsumeToken();
} while (1);
- // FIXME: Need to actually grab the data and pass it on to Sema. Ideally,
- // what Sema wants is a string of the entire inline asm, with one instruction
- // per line and all the __asm keywords stripped out, and a way of mapping
- // from any character of that string to its location in the original source
- // code. I'm not entirely sure how to go about that, though.
- Token t;
- t.setKind(tok::string_literal);
- t.setLiteralData("\"/*FIXME: not done*/\"");
- t.clearFlag(Token::NeedsCleaning);
- t.setLength(21);
- ExprResult AsmString(Actions.ActOnStringLiteral(&t, 1));
- ExprVector Constraints(Actions);
- ExprVector Exprs(Actions);
- ExprVector Clobbers(Actions);
- return Actions.ActOnAsmStmt(AsmLoc, true, true, 0, 0, 0,
- move_arg(Constraints), move_arg(Exprs),
- AsmString.take(), move_arg(Clobbers),
- EndLoc, true);
+
+ // Collect the tokens into a string
+ SmallString<512> Asm;
+ SmallString<512> TokenBuf;
+ TokenBuf.resize(512);
+ unsigned AsmLineNum = 0;
+ for (unsigned i = 0, e = AsmToks.size(); i < e; ++i) {
+ const char *ThisTokBuf = &TokenBuf[0];
+ bool StringInvalid = false;
+ unsigned ThisTokLen =
+ Lexer::getSpelling(AsmToks[i], ThisTokBuf, PP.getSourceManager(),
+ PP.getLangOpts(), &StringInvalid);
+ if (i && (!AsmLineNum || i != LineEnds[AsmLineNum-1]) &&
+ needSpaceAsmToken(AsmToks[i]))
+ Asm += ' ';
+ Asm += StringRef(ThisTokBuf, ThisTokLen);
+ if (i + 1 == LineEnds[AsmLineNum] && i + 1 != AsmToks.size()) {
+ Asm += '\n';
+ ++AsmLineNum;
+ }
+ }
+
+ // FIXME: We should be passing the tokens and source locations, rather than
+ // (or possibly in addition to the) AsmString. Sema is going to interact with
+ // MC to determine Constraints, Clobbers, etc., which would be simplest to
+ // do with the tokens.
+ std::string AsmString = Asm.c_str();
+ return Actions.ActOnMSAsmStmt(AsmLoc, AsmString, EndLoc);
}
/// ParseAsmStatement - Parse a GNU extended asm statement.
@@ -1758,18 +1831,6 @@
/// asm-string-literal
/// asm-clobbers ',' asm-string-literal
///
-/// [MS] ms-asm-statement:
-/// ms-asm-block
-/// ms-asm-block ms-asm-statement
-///
-/// [MS] ms-asm-block:
-/// '__asm' ms-asm-line '\n'
-/// '__asm' '{' ms-asm-instruction-block[opt] '}' ';'[opt]
-///
-/// [MS] ms-asm-instruction-block
-/// ms-asm-line
-/// ms-asm-line '\n' ms-asm-instruction-block
-///
StmtResult Parser::ParseAsmStatement(bool &msAsm) {
assert(Tok.is(tok::kw_asm) && "Not an asm stmt");
SourceLocation AsmLoc = ConsumeToken();
Modified: cfe/branches/tooling/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/Parser.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/Parser.cpp (original)
+++ cfe/branches/tooling/lib/Parse/Parser.cpp Fri Jun 15 06:08:27 2012
@@ -59,7 +59,7 @@
MSStructHandler.reset(new PragmaMSStructHandler(actions));
PP.AddPragmaHandler(MSStructHandler.get());
- UnusedHandler.reset(new PragmaUnusedHandler(actions, *this));
+ UnusedHandler.reset(new PragmaUnusedHandler(actions));
PP.AddPragmaHandler(UnusedHandler.get());
WeakHandler.reset(new PragmaWeakHandler(actions));
@@ -68,12 +68,11 @@
RedefineExtnameHandler.reset(new PragmaRedefineExtnameHandler(actions));
PP.AddPragmaHandler(RedefineExtnameHandler.get());
- FPContractHandler.reset(new PragmaFPContractHandler(actions, *this));
+ FPContractHandler.reset(new PragmaFPContractHandler(actions));
PP.AddPragmaHandler("STDC", FPContractHandler.get());
if (getLangOpts().OpenCL) {
- OpenCLExtensionHandler.reset(
- new PragmaOpenCLExtensionHandler(actions, *this));
+ OpenCLExtensionHandler.reset(new PragmaOpenCLExtensionHandler(actions));
PP.AddPragmaHandler("OPENCL", OpenCLExtensionHandler.get());
PP.AddPragmaHandler("OPENCL", FPContractHandler.get());
@@ -439,10 +438,6 @@
// Prime the lexer look-ahead.
ConsumeToken();
- if (Tok.is(tok::eof) &&
- !getLangOpts().CPlusPlus) // Empty source file is an extension in C
- Diag(Tok, diag::ext_empty_source_file);
-
// Initialization for Objective-C context sensitive keywords recognition.
// Referenced in Parser::ParseObjCTypeQualifierList.
if (getLangOpts().ObjC1) {
@@ -1709,13 +1704,13 @@
return Actions.ConvertDeclToDeclGroup(Import.get());
}
-bool Parser::BalancedDelimiterTracker::diagnoseOverflow() {
+bool BalancedDelimiterTracker::diagnoseOverflow() {
P.Diag(P.Tok, diag::err_parser_impl_limit_overflow);
P.SkipUntil(tok::eof);
return true;
}
-bool Parser::BalancedDelimiterTracker::expectAndConsume(unsigned DiagID,
+bool BalancedDelimiterTracker::expectAndConsume(unsigned DiagID,
const char *Msg,
tok::TokenKind SkipToToc ) {
LOpen = P.Tok.getLocation();
@@ -1728,7 +1723,7 @@
return diagnoseOverflow();
}
-bool Parser::BalancedDelimiterTracker::diagnoseMissingClose() {
+bool BalancedDelimiterTracker::diagnoseMissingClose() {
assert(!P.Tok.is(Close) && "Should have consumed closing delimiter");
const char *LHSName = "unknown";
@@ -1746,6 +1741,6 @@
return true;
}
-void Parser::BalancedDelimiterTracker::skipToEnd() {
+void BalancedDelimiterTracker::skipToEnd() {
P.SkipUntil(Close, false);
}
Modified: cfe/branches/tooling/lib/Parse/RAIIObjectsForParser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/RAIIObjectsForParser.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/RAIIObjectsForParser.h (original)
+++ cfe/branches/tooling/lib/Parse/RAIIObjectsForParser.h Fri Jun 15 06:08:27 2012
@@ -332,6 +332,81 @@
}
};
+ /// \brief RAII class that helps handle the parsing of an open/close delimiter
+ /// pair, such as braces { ... } or parentheses ( ... ).
+ class BalancedDelimiterTracker : public GreaterThanIsOperatorScope {
+ Parser& P;
+ tok::TokenKind Kind, Close;
+ SourceLocation (Parser::*Consumer)();
+ SourceLocation LOpen, LClose;
+
+ unsigned short &getDepth() {
+ switch (Kind) {
+ case tok::l_brace: return P.BraceCount;
+ case tok::l_square: return P.BracketCount;
+ case tok::l_paren: return P.ParenCount;
+ default: llvm_unreachable("Wrong token kind");
+ }
+ }
+
+ enum { MaxDepth = 256 };
+
+ bool diagnoseOverflow();
+ bool diagnoseMissingClose();
+
+ public:
+ BalancedDelimiterTracker(Parser& p, tok::TokenKind k)
+ : GreaterThanIsOperatorScope(p.GreaterThanIsOperator, true),
+ P(p), Kind(k)
+ {
+ switch (Kind) {
+ default: llvm_unreachable("Unexpected balanced token");
+ case tok::l_brace:
+ Close = tok::r_brace;
+ Consumer = &Parser::ConsumeBrace;
+ break;
+ case tok::l_paren:
+ Close = tok::r_paren;
+ Consumer = &Parser::ConsumeParen;
+ break;
+
+ case tok::l_square:
+ Close = tok::r_square;
+ Consumer = &Parser::ConsumeBracket;
+ break;
+ }
+ }
+
+ SourceLocation getOpenLocation() const { return LOpen; }
+ SourceLocation getCloseLocation() const { return LClose; }
+ SourceRange getRange() const { return SourceRange(LOpen, LClose); }
+
+ bool consumeOpen() {
+ if (!P.Tok.is(Kind))
+ return true;
+
+ if (getDepth() < MaxDepth) {
+ LOpen = (P.*Consumer)();
+ return false;
+ }
+
+ return diagnoseOverflow();
+ }
+
+ bool expectAndConsume(unsigned DiagID,
+ const char *Msg = "",
+ tok::TokenKind SkipToTok = tok::unknown);
+ bool consumeClose() {
+ if (P.Tok.is(Close)) {
+ LClose = (P.*Consumer)();
+ return false;
+ }
+
+ return diagnoseMissingClose();
+ }
+ void skipToEnd();
+ };
+
} // end namespace clang
#endif
Modified: cfe/branches/tooling/lib/Rewrite/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Rewrite/CMakeLists.txt?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Rewrite/CMakeLists.txt (original)
+++ cfe/branches/tooling/lib/Rewrite/CMakeLists.txt Fri Jun 15 06:08:27 2012
@@ -6,6 +6,7 @@
FrontendActions.cpp
HTMLPrint.cpp
HTMLRewrite.cpp
+ InclusionRewriter.cpp
RewriteMacros.cpp
RewriteModernObjC.cpp
RewriteObjC.cpp
Modified: cfe/branches/tooling/lib/Rewrite/FrontendActions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Rewrite/FrontendActions.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Rewrite/FrontendActions.cpp (original)
+++ cfe/branches/tooling/lib/Rewrite/FrontendActions.cpp Fri Jun 15 06:08:27 2012
@@ -181,3 +181,12 @@
DoRewriteTest(CI.getPreprocessor(), OS);
}
+
+void RewriteIncludesAction::ExecuteAction() {
+ CompilerInstance &CI = getCompilerInstance();
+ raw_ostream *OS = CI.createDefaultOutputFile(true, getCurrentFile());
+ if (!OS) return;
+
+ RewriteIncludesInInput(CI.getPreprocessor(), OS,
+ CI.getPreprocessorOutputOpts());
+}
Modified: cfe/branches/tooling/lib/Rewrite/HTMLRewrite.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Rewrite/HTMLRewrite.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Rewrite/HTMLRewrite.cpp (original)
+++ cfe/branches/tooling/lib/Rewrite/HTMLRewrite.cpp Fri Jun 15 06:08:27 2012
@@ -495,6 +495,11 @@
// Inform the preprocessor that we don't want comments.
TmpPP.SetCommentRetentionState(false, false);
+ // We don't want pragmas either. Although we filtered out #pragma, removing
+ // _Pragma and __pragma is much harder.
+ bool PragmasPreviouslyEnabled = TmpPP.getPragmasEnabled();
+ TmpPP.setPragmasEnabled(false);
+
// Enter the tokens we just lexed. This will cause them to be macro expanded
// but won't enter sub-files (because we removed #'s).
TmpPP.EnterTokenStream(&TokenStream[0], TokenStream.size(), false, false);
@@ -571,6 +576,7 @@
"<span class='macro'>", Expansion.c_str());
}
- // Restore diagnostics object back to its own thing.
+ // Restore the preprocessor's old state.
TmpPP.setDiagnostics(*OldDiags);
+ TmpPP.setPragmasEnabled(PragmasPreviouslyEnabled);
}
Modified: cfe/branches/tooling/lib/Rewrite/RewriteModernObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Rewrite/RewriteModernObjC.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Rewrite/RewriteModernObjC.cpp (original)
+++ cfe/branches/tooling/lib/Rewrite/RewriteModernObjC.cpp Fri Jun 15 06:08:27 2012
@@ -823,7 +823,7 @@
&Context->Idents.get(D->getNameAsString()),
IvarT, 0,
/*BitWidth=*/0, /*Mutable=*/true,
- /*HasInit=*/false);
+ ICIS_NoInit);
MemberExpr *ME = new (Context) MemberExpr(PE, true, FD, SourceLocation(),
FD->getType(), VK_LValue,
OK_Ordinary);
@@ -1077,7 +1077,7 @@
for (ObjCCategoryDecl::prop_iterator I = CatDecl->prop_begin(),
E = CatDecl->prop_end(); I != E; ++I)
- RewriteProperty(&*I);
+ RewriteProperty(*I);
for (ObjCCategoryDecl::instmeth_iterator
I = CatDecl->instmeth_begin(), E = CatDecl->instmeth_end();
@@ -1111,7 +1111,7 @@
for (ObjCInterfaceDecl::prop_iterator I = PDecl->prop_begin(),
E = PDecl->prop_end(); I != E; ++I)
- RewriteProperty(&*I);
+ RewriteProperty(*I);
// Lastly, comment out the @end.
SourceLocation LocEnd = PDecl->getAtEndRange().getBegin();
@@ -1343,7 +1343,7 @@
I = IMD ? IMD->propimpl_begin() : CID->propimpl_begin(),
E = IMD ? IMD->propimpl_end() : CID->propimpl_end();
I != E; ++I) {
- RewritePropertyImplDecl(&*I, IMD, CID);
+ RewritePropertyImplDecl(*I, IMD, CID);
}
InsertText(IMD ? IMD->getLocEnd() : CID->getLocEnd(), "// ");
@@ -1371,7 +1371,7 @@
for (ObjCInterfaceDecl::prop_iterator I = ClassDecl->prop_begin(),
E = ClassDecl->prop_end(); I != E; ++I)
- RewriteProperty(&*I);
+ RewriteProperty(*I);
for (ObjCInterfaceDecl::instmeth_iterator
I = ClassDecl->instmeth_begin(), E = ClassDecl->instmeth_end();
I != E; ++I)
@@ -2720,7 +2720,7 @@
&Context->Idents.get("arr"),
Context->getPointerType(Context->VoidPtrTy), 0,
/*BitWidth=*/0, /*Mutable=*/true,
- /*HasInit=*/false);
+ ICIS_NoInit);
MemberExpr *ArrayLiteralME =
new (Context) MemberExpr(NSArrayCallExpr, false, ARRFD,
SourceLocation(),
@@ -2867,7 +2867,7 @@
&Context->Idents.get("arr"),
Context->getPointerType(Context->VoidPtrTy), 0,
/*BitWidth=*/0, /*Mutable=*/true,
- /*HasInit=*/false);
+ ICIS_NoInit);
MemberExpr *DictLiteralValueME =
new (Context) MemberExpr(NSValueCallExpr, false, ARRFD,
SourceLocation(),
@@ -3014,7 +3014,7 @@
FieldTypes[i], 0,
/*BitWidth=*/0,
/*Mutable=*/false,
- /*HasInit=*/false));
+ ICIS_NoInit));
}
SuperStructDecl->completeDefinition();
@@ -3047,7 +3047,7 @@
FieldTypes[i], 0,
/*BitWidth=*/0,
/*Mutable=*/true,
- /*HasInit=*/false));
+ ICIS_NoInit));
}
ConstantStringDecl->completeDefinition();
@@ -3636,7 +3636,7 @@
Result += " {\n";
for (RecordDecl::field_iterator i = RD->field_begin(),
e = RD->field_end(); i != e; ++i) {
- FieldDecl *FD = &*i;
+ FieldDecl *FD = *i;
RewriteObjCFieldDecl(FD, Result);
}
Result += "\t} ";
@@ -4491,7 +4491,7 @@
&Context->Idents.get("FuncPtr"),
Context->VoidPtrTy, 0,
/*BitWidth=*/0, /*Mutable=*/true,
- /*HasInit=*/false);
+ ICIS_NoInit);
MemberExpr *ME = new (Context) MemberExpr(PE, true, FD, SourceLocation(),
FD->getType(), VK_LValue,
OK_Ordinary);
@@ -4540,7 +4540,7 @@
&Context->Idents.get("__forwarding"),
Context->VoidPtrTy, 0,
/*BitWidth=*/0, /*Mutable=*/true,
- /*HasInit=*/false);
+ ICIS_NoInit);
MemberExpr *ME = new (Context) MemberExpr(DeclRefExp, isArrow,
FD, SourceLocation(),
FD->getType(), VK_LValue,
@@ -4551,7 +4551,7 @@
&Context->Idents.get(Name),
Context->VoidPtrTy, 0,
/*BitWidth=*/0, /*Mutable=*/true,
- /*HasInit=*/false);
+ ICIS_NoInit);
ME = new (Context) MemberExpr(ME, true, FD, SourceLocation(),
DeclRefExp->getType(), VK_LValue, OK_Ordinary);
@@ -5549,7 +5549,7 @@
void RewriteModernObjC::RewriteRecordBody(RecordDecl *RD) {
for (RecordDecl::field_iterator i = RD->field_begin(),
e = RD->field_end(); i != e; ++i) {
- FieldDecl *FD = &*i;
+ FieldDecl *FD = *i;
if (isTopLevelBlockPointerType(FD->getType()))
RewriteBlockPointerDecl(FD);
if (FD->getType()->isObjCQualifiedIdType() ||
@@ -6750,7 +6750,7 @@
std::vector<ObjCPropertyDecl *> ProtocolProperties;
for (ObjCContainerDecl::prop_iterator I = PDecl->prop_begin(),
E = PDecl->prop_end(); I != E; ++I)
- ProtocolProperties.push_back(&*I);
+ ProtocolProperties.push_back(*I);
Write_prop_list_t_initializer(*this, Context, Result, ProtocolProperties,
/* Container */0,
@@ -6971,7 +6971,7 @@
std::vector<ObjCPropertyDecl *> ClassProperties;
for (ObjCContainerDecl::prop_iterator I = CDecl->prop_begin(),
E = CDecl->prop_end(); I != E; ++I)
- ClassProperties.push_back(&*I);
+ ClassProperties.push_back(*I);
Write_prop_list_t_initializer(*this, Context, Result, ClassProperties,
/* Container */IDecl,
@@ -7233,7 +7233,7 @@
std::vector<ObjCPropertyDecl *> ClassProperties;
for (ObjCContainerDecl::prop_iterator I = CDecl->prop_begin(),
E = CDecl->prop_end(); I != E; ++I)
- ClassProperties.push_back(&*I);
+ ClassProperties.push_back(*I);
Write_prop_list_t_initializer(*this, Context, Result, ClassProperties,
/* Container */IDecl,
@@ -7436,7 +7436,7 @@
&Context->Idents.get(D->getNameAsString()),
IvarT, 0,
/*BitWidth=*/0, /*Mutable=*/true,
- /*HasInit=*/false);
+ ICIS_NoInit);
MemberExpr *ME = new (Context) MemberExpr(PE, true, FD, SourceLocation(),
FD->getType(), VK_LValue,
OK_Ordinary);
Modified: cfe/branches/tooling/lib/Rewrite/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Rewrite/RewriteObjC.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Rewrite/RewriteObjC.cpp (original)
+++ cfe/branches/tooling/lib/Rewrite/RewriteObjC.cpp Fri Jun 15 06:08:27 2012
@@ -967,7 +967,7 @@
for (ObjCCategoryDecl::prop_iterator I = CatDecl->prop_begin(),
E = CatDecl->prop_end(); I != E; ++I)
- RewriteProperty(&*I);
+ RewriteProperty(*I);
for (ObjCCategoryDecl::instmeth_iterator
I = CatDecl->instmeth_begin(), E = CatDecl->instmeth_end();
@@ -1001,7 +1001,7 @@
for (ObjCInterfaceDecl::prop_iterator I = PDecl->prop_begin(),
E = PDecl->prop_end(); I != E; ++I)
- RewriteProperty(&*I);
+ RewriteProperty(*I);
// Lastly, comment out the @end.
SourceLocation LocEnd = PDecl->getAtEndRange().getBegin();
@@ -1207,7 +1207,7 @@
I = IMD ? IMD->propimpl_begin() : CID->propimpl_begin(),
E = IMD ? IMD->propimpl_end() : CID->propimpl_end();
I != E; ++I) {
- RewritePropertyImplDecl(&*I, IMD, CID);
+ RewritePropertyImplDecl(*I, IMD, CID);
}
InsertText(IMD ? IMD->getLocEnd() : CID->getLocEnd(), "// ");
@@ -1233,7 +1233,7 @@
for (ObjCInterfaceDecl::prop_iterator I = ClassDecl->prop_begin(),
E = ClassDecl->prop_end(); I != E; ++I)
- RewriteProperty(&*I);
+ RewriteProperty(*I);
for (ObjCInterfaceDecl::instmeth_iterator
I = ClassDecl->instmeth_begin(), E = ClassDecl->instmeth_end();
I != E; ++I)
@@ -2592,7 +2592,7 @@
FieldTypes[i], 0,
/*BitWidth=*/0,
/*Mutable=*/false,
- /*HasInit=*/false));
+ ICIS_NoInit));
}
SuperStructDecl->completeDefinition();
@@ -2625,7 +2625,7 @@
FieldTypes[i], 0,
/*BitWidth=*/0,
/*Mutable=*/true,
- /*HasInit=*/false));
+ ICIS_NoInit));
}
ConstantStringDecl->completeDefinition();
@@ -3887,7 +3887,7 @@
&Context->Idents.get("FuncPtr"),
Context->VoidPtrTy, 0,
/*BitWidth=*/0, /*Mutable=*/true,
- /*HasInit=*/false);
+ ICIS_NoInit);
MemberExpr *ME = new (Context) MemberExpr(PE, true, FD, SourceLocation(),
FD->getType(), VK_LValue,
OK_Ordinary);
@@ -3936,7 +3936,7 @@
&Context->Idents.get("__forwarding"),
Context->VoidPtrTy, 0,
/*BitWidth=*/0, /*Mutable=*/true,
- /*HasInit=*/false);
+ ICIS_NoInit);
MemberExpr *ME = new (Context) MemberExpr(DeclRefExp, isArrow,
FD, SourceLocation(),
FD->getType(), VK_LValue,
@@ -3947,7 +3947,7 @@
&Context->Idents.get(Name),
Context->VoidPtrTy, 0,
/*BitWidth=*/0, /*Mutable=*/true,
- /*HasInit=*/false);
+ ICIS_NoInit);
ME = new (Context) MemberExpr(ME, true, FD, SourceLocation(),
DeclRefExp->getType(), VK_LValue, OK_Ordinary);
@@ -4881,7 +4881,7 @@
void RewriteObjC::RewriteRecordBody(RecordDecl *RD) {
for (RecordDecl::field_iterator i = RD->field_begin(),
e = RD->field_end(); i != e; ++i) {
- FieldDecl *FD = &*i;
+ FieldDecl *FD = *i;
if (isTopLevelBlockPointerType(FD->getType()))
RewriteBlockPointerDecl(FD);
if (FD->getType()->isObjCQualifiedIdType() ||
@@ -5434,7 +5434,7 @@
for (ObjCInterfaceDecl::ivar_iterator
IV = IDecl->ivar_begin(), IVEnd = IDecl->ivar_end();
IV != IVEnd; ++IV)
- IVars.push_back(&*IV);
+ IVars.push_back(*IV);
IVI = IDecl->ivar_begin();
IVE = IDecl->ivar_end();
} else {
@@ -5445,22 +5445,22 @@
Result += IVI->getNameAsString();
Result += "\", \"";
std::string TmpString, StrEncoding;
- Context->getObjCEncodingForType(IVI->getType(), TmpString, &*IVI);
+ Context->getObjCEncodingForType(IVI->getType(), TmpString, *IVI);
QuoteDoublequotes(TmpString, StrEncoding);
Result += StrEncoding;
Result += "\", ";
- RewriteIvarOffsetComputation(&*IVI, Result);
+ RewriteIvarOffsetComputation(*IVI, Result);
Result += "}\n";
for (++IVI; IVI != IVE; ++IVI) {
Result += "\t ,{\"";
Result += IVI->getNameAsString();
Result += "\", \"";
std::string TmpString, StrEncoding;
- Context->getObjCEncodingForType(IVI->getType(), TmpString, &*IVI);
+ Context->getObjCEncodingForType(IVI->getType(), TmpString, *IVI);
QuoteDoublequotes(TmpString, StrEncoding);
Result += StrEncoding;
Result += "\", ";
- RewriteIvarOffsetComputation(&*IVI, Result);
+ RewriteIvarOffsetComputation(*IVI, Result);
Result += "}\n";
}
@@ -6015,4 +6015,3 @@
ReplaceStmtWithRange(IV, Replacement, OldRange);
return Replacement;
}
-
Modified: cfe/branches/tooling/lib/Sema/AnalysisBasedWarnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/AnalysisBasedWarnings.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/branches/tooling/lib/Sema/AnalysisBasedWarnings.cpp Fri Jun 15 06:08:27 2012
@@ -189,6 +189,12 @@
continue;
}
}
+ if (isa<MSAsmStmt>(S)) {
+ // TODO: Verify this is correct.
+ HasFakeEdge = true;
+ HasLiveReturn = true;
+ continue;
+ }
if (isa<CXXTryStmt>(S)) {
HasAbnormalEdge = true;
continue;
Modified: cfe/branches/tooling/lib/Sema/DeclSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/DeclSpec.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/DeclSpec.cpp (original)
+++ cfe/branches/tooling/lib/Sema/DeclSpec.cpp Fri Jun 15 06:08:27 2012
@@ -165,7 +165,7 @@
SourceLocation LocalRangeBegin,
SourceLocation LocalRangeEnd,
Declarator &TheDeclarator,
- ParsedType TrailingReturnType) {
+ TypeResult TrailingReturnType) {
DeclaratorChunk I;
I.Kind = Function;
I.Loc = LocalRangeBegin;
@@ -188,7 +188,9 @@
I.Fun.NumExceptions = 0;
I.Fun.Exceptions = 0;
I.Fun.NoexceptExpr = 0;
- I.Fun.TrailingReturnType = TrailingReturnType.getAsOpaquePtr();
+ I.Fun.HasTrailingReturnType = TrailingReturnType.isUsable() ||
+ TrailingReturnType.isInvalid();
+ I.Fun.TrailingReturnType = TrailingReturnType.get();
// new[] an argument array if needed.
if (NumArgs) {
Modified: cfe/branches/tooling/lib/Sema/IdentifierResolver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/IdentifierResolver.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/IdentifierResolver.cpp (original)
+++ cfe/branches/tooling/lib/Sema/IdentifierResolver.cpp Fri Jun 15 06:08:27 2012
@@ -304,7 +304,7 @@
for (Decl::redecl_iterator RD = New->redecls_begin(),
RDEnd = New->redecls_end();
RD != RDEnd; ++RD) {
- if (RD == Existing)
+ if (*RD == Existing)
return DMK_Replace;
if (RD->isCanonicalDecl())
Modified: cfe/branches/tooling/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/Sema.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/Sema.cpp (original)
+++ cfe/branches/tooling/lib/Sema/Sema.cpp Fri Jun 15 06:08:27 2012
@@ -444,6 +444,8 @@
I != E && Complete; ++I) {
if (const CXXMethodDecl *M = dyn_cast<CXXMethodDecl>(*I))
Complete = M->isDefined() || (M->isPure() && !isa<CXXDestructorDecl>(M));
+ else if (const FunctionTemplateDecl *F = dyn_cast<FunctionTemplateDecl>(*I))
+ Complete = F->getTemplatedDecl()->isDefined();
else if (const CXXRecordDecl *R = dyn_cast<CXXRecordDecl>(*I)) {
if (R->isInjectedClassName())
continue;
Modified: cfe/branches/tooling/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaChecking.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaChecking.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaChecking.cpp Fri Jun 15 06:08:27 2012
@@ -2633,7 +2633,7 @@
bool inFunctionCall) {
// CHECK: is the format string a wide literal?
- if (!FExpr->isAscii()) {
+ if (!FExpr->isAscii() && !FExpr->isUTF8()) {
CheckFormatHandler::EmitFormatDiagnostic(
*this, inFunctionCall, Args[format_idx],
PDiag(diag::warn_format_string_is_wide_literal), FExpr->getLocStart(),
Modified: cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp Fri Jun 15 06:08:27 2012
@@ -158,7 +158,7 @@
/// \brief The completion context in which we are gathering results.
CodeCompletionContext CompletionContext;
- /// \brief If we are in an instance method definition, the @implementation
+ /// \brief If we are in an instance method definition, the \@implementation
/// object.
ObjCImplementationDecl *ObjCImplementation;
@@ -3271,9 +3271,6 @@
/// \brief Perform code-completion in an expression context when we know what
/// type we're looking for.
-///
-/// \param IntegralConstantExpression Only permit integral constant
-/// expressions.
void Sema::CodeCompleteExpression(Scope *S,
const CodeCompleteExpressionData &Data) {
typedef CodeCompletionResult Result;
@@ -3334,7 +3331,25 @@
/// property name.
typedef llvm::SmallPtrSet<IdentifierInfo*, 16> AddedPropertiesSet;
-static void AddObjCProperties(ObjCContainerDecl *Container,
+/// \brief Retrieve the container definition, if any?
+static ObjCContainerDecl *getContainerDef(ObjCContainerDecl *Container) {
+ if (ObjCInterfaceDecl *Interface = dyn_cast<ObjCInterfaceDecl>(Container)) {
+ if (Interface->hasDefinition())
+ return Interface->getDefinition();
+
+ return Interface;
+ }
+
+ if (ObjCProtocolDecl *Protocol = dyn_cast<ObjCProtocolDecl>(Container)) {
+ if (Protocol->hasDefinition())
+ return Protocol->getDefinition();
+
+ return Protocol;
+ }
+ return Container;
+}
+
+static void AddObjCProperties(ObjCContainerDecl *Container,
bool AllowCategories,
bool AllowNullaryMethods,
DeclContext *CurContext,
@@ -3342,13 +3357,16 @@
ResultBuilder &Results) {
typedef CodeCompletionResult Result;
+ // Retrieve the definition.
+ Container = getContainerDef(Container);
+
// Add properties in this container.
for (ObjCContainerDecl::prop_iterator P = Container->prop_begin(),
PEnd = Container->prop_end();
P != PEnd;
++P) {
if (AddedProperties.insert(P->getIdentifier()))
- Results.MaybeAddResult(Result(&*P, 0), CurContext);
+ Results.MaybeAddResult(Result(*P, 0), CurContext);
}
// Add nullary methods
@@ -3363,11 +3381,11 @@
if (AddedProperties.insert(Name)) {
CodeCompletionBuilder Builder(Results.getAllocator(),
Results.getCodeCompletionTUInfo());
- AddResultTypeChunk(Context, Policy, &*M, Builder);
+ AddResultTypeChunk(Context, Policy, *M, Builder);
Builder.AddTypedTextChunk(
Results.getAllocator().CopyString(Name->getName()));
- Results.MaybeAddResult(Result(Builder.TakeString(), &*M,
+ Results.MaybeAddResult(Result(Builder.TakeString(), *M,
CCP_MemberDeclaration + CCD_MethodAsProperty),
CurContext);
}
@@ -3617,6 +3635,8 @@
// Code-complete the cases of a switch statement over an enumeration type
// by providing the list of
EnumDecl *Enum = type->castAs<EnumType>()->getDecl();
+ if (EnumDecl *Def = Enum->getDefinition())
+ Enum = Def;
// Determine which enumerators we have already seen in the switch statement.
// FIXME: Ideally, we would also be able to look *past* the code-completion
@@ -3672,10 +3692,10 @@
for (EnumDecl::enumerator_iterator E = Enum->enumerator_begin(),
EEnd = Enum->enumerator_end();
E != EEnd; ++E) {
- if (EnumeratorsSeen.count(&*E))
+ if (EnumeratorsSeen.count(*E))
continue;
- CodeCompletionResult R(&*E, Qualifier);
+ CodeCompletionResult R(*E, Qualifier);
R.Priority = CCP_EnumInCase;
Results.AddResult(R, CurContext, 0, false);
}
@@ -4037,7 +4057,7 @@
for (DeclContext::specific_decl_iterator<NamespaceDecl>
NS(Ctx->decls_begin()), NSEnd(Ctx->decls_end());
NS != NSEnd; ++NS)
- OrigToLatest[NS->getOriginalNamespace()] = &*NS;
+ OrigToLatest[NS->getOriginalNamespace()] = *NS;
// Add the most recent definition (or extended definition) of each
// namespace to the list of results.
@@ -4193,7 +4213,7 @@
SawLastInitializer
= NumInitializers > 0 &&
Initializers[NumInitializers - 1]->isAnyMemberInitializer() &&
- Initializers[NumInitializers - 1]->getAnyMember() == &*Field;
+ Initializers[NumInitializers - 1]->getAnyMember() == *Field;
continue;
}
@@ -4210,7 +4230,7 @@
: CCP_MemberDeclaration,
CXCursor_MemberRef,
CXAvailability_Available,
- &*Field));
+ *Field));
SawLastInitializer = false;
}
Results.ExitScope();
@@ -4274,27 +4294,28 @@
Results.data(), Results.size());
}
-// Macro that expands to @Keyword or Keyword, depending on whether NeedAt is
-// true or false.
-#define OBJC_AT_KEYWORD_NAME(NeedAt,Keyword) NeedAt? "@" #Keyword : #Keyword
+/// Macro that optionally prepends an "@" to the string literal passed in via
+/// Keyword, depending on whether NeedAt is true or false.
+#define OBJC_AT_KEYWORD_NAME(NeedAt,Keyword) ((NeedAt)? "@" Keyword : Keyword)
+
static void AddObjCImplementationResults(const LangOptions &LangOpts,
ResultBuilder &Results,
bool NeedAt) {
typedef CodeCompletionResult Result;
// Since we have an implementation, we can end it.
- Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,end)));
+ Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,"end")));
CodeCompletionBuilder Builder(Results.getAllocator(),
Results.getCodeCompletionTUInfo());
if (LangOpts.ObjC2) {
// @dynamic
- Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,dynamic));
+ Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,"dynamic"));
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
Builder.AddPlaceholderChunk("property");
Results.AddResult(Result(Builder.TakeString()));
// @synthesize
- Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,synthesize));
+ Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,"synthesize"));
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
Builder.AddPlaceholderChunk("property");
Results.AddResult(Result(Builder.TakeString()));
@@ -4307,17 +4328,17 @@
typedef CodeCompletionResult Result;
// Since we have an interface or protocol, we can end it.
- Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,end)));
+ Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,"end")));
if (LangOpts.ObjC2) {
// @property
- Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,property)));
+ Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,"property")));
// @required
- Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,required)));
+ Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,"required")));
// @optional
- Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,optional)));
+ Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,"optional")));
}
}
@@ -4327,7 +4348,7 @@
Results.getCodeCompletionTUInfo());
// @class name ;
- Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,class));
+ Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,"class"));
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
Builder.AddPlaceholderChunk("name");
Results.AddResult(Result(Builder.TakeString()));
@@ -4336,26 +4357,26 @@
// @interface name
// FIXME: Could introduce the whole pattern, including superclasses and
// such.
- Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,interface));
+ Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,"interface"));
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
Builder.AddPlaceholderChunk("class");
Results.AddResult(Result(Builder.TakeString()));
// @protocol name
- Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,protocol));
+ Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,"protocol"));
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
Builder.AddPlaceholderChunk("protocol");
Results.AddResult(Result(Builder.TakeString()));
// @implementation name
- Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,implementation));
+ Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,"implementation"));
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
Builder.AddPlaceholderChunk("class");
Results.AddResult(Result(Builder.TakeString()));
}
// @compatibility_alias name
- Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,compatibility_alias));
+ Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,"compatibility_alias"));
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
Builder.AddPlaceholderChunk("alias");
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
@@ -4392,7 +4413,7 @@
Results.getSema().getLangOpts().ConstStrings)
EncodeType = " const char[]";
Builder.AddResultTypeChunk(EncodeType);
- Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,encode));
+ Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,"encode"));
Builder.AddChunk(CodeCompletionString::CK_LeftParen);
Builder.AddPlaceholderChunk("type-name");
Builder.AddChunk(CodeCompletionString::CK_RightParen);
@@ -4400,7 +4421,7 @@
// @protocol ( protocol-name )
Builder.AddResultTypeChunk("Protocol *");
- Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,protocol));
+ Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,"protocol"));
Builder.AddChunk(CodeCompletionString::CK_LeftParen);
Builder.AddPlaceholderChunk("protocol-name");
Builder.AddChunk(CodeCompletionString::CK_RightParen);
@@ -4408,14 +4429,14 @@
// @selector ( selector )
Builder.AddResultTypeChunk("SEL");
- Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,selector));
+ Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,"selector"));
Builder.AddChunk(CodeCompletionString::CK_LeftParen);
Builder.AddPlaceholderChunk("selector");
Builder.AddChunk(CodeCompletionString::CK_RightParen);
Results.AddResult(Result(Builder.TakeString()));
// @[ objects, ... ]
- Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,[));
+ Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,"["));
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
Builder.AddPlaceholderChunk("objects, ...");
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
@@ -4423,7 +4444,7 @@
Results.AddResult(Result(Builder.TakeString()));
// @{ key : object, ... }
- Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,{));
+ Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,"{"));
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
Builder.AddPlaceholderChunk("key");
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
@@ -4443,7 +4464,7 @@
if (Results.includeCodePatterns()) {
// @try { statements } @catch ( declaration ) { statements } @finally
// { statements }
- Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,try));
+ Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,"try"));
Builder.AddChunk(CodeCompletionString::CK_LeftBrace);
Builder.AddPlaceholderChunk("statements");
Builder.AddChunk(CodeCompletionString::CK_RightBrace);
@@ -4462,14 +4483,14 @@
}
// @throw
- Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,throw));
+ Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,"throw"));
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
Builder.AddPlaceholderChunk("expression");
Results.AddResult(Result(Builder.TakeString()));
if (Results.includeCodePatterns()) {
// @synchronized ( expression ) { statements }
- Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,synchronized));
+ Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,"synchronized"));
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
Builder.AddChunk(CodeCompletionString::CK_LeftParen);
Builder.AddPlaceholderChunk("expression");
@@ -4485,11 +4506,11 @@
ResultBuilder &Results,
bool NeedAt) {
typedef CodeCompletionResult Result;
- Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,private)));
- Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,protected)));
- Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,public)));
+ Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,"private")));
+ Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,"protected")));
+ Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,"public")));
if (LangOpts.ObjC2)
- Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,package)));
+ Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,"package")));
}
void Sema::CodeCompleteObjCAtVisibility(Scope *S) {
@@ -4620,9 +4641,9 @@
/// \brief Descripts the kind of Objective-C method that we want to find
/// via code completion.
enum ObjCMethodKind {
- MK_Any, //< Any kind of method, provided it means other specified criteria.
- MK_ZeroArgSelector, //< Zero-argument (unary) selector.
- MK_OneArgSelector //< One-argument selector.
+ MK_Any, ///< Any kind of method, provided it means other specified criteria.
+ MK_ZeroArgSelector, ///< Zero-argument (unary) selector.
+ MK_OneArgSelector ///< One-argument selector.
};
static bool isAcceptableObjCSelector(Selector Sel,
@@ -4674,8 +4695,8 @@
///
/// \param Container the container in which we'll look to find methods.
///
-/// \param WantInstance whether to add instance methods (only); if false, this
-/// routine will add factory methods (only).
+/// \param WantInstanceMethods Whether to add instance methods (only); if
+/// false, this routine will add factory methods (only).
///
/// \param CurContext the context in which we're performing the lookup that
/// finds methods.
@@ -4695,20 +4716,21 @@
ResultBuilder &Results,
bool InOriginalClass = true) {
typedef CodeCompletionResult Result;
+ Container = getContainerDef(Container);
for (ObjCContainerDecl::method_iterator M = Container->meth_begin(),
MEnd = Container->meth_end();
M != MEnd; ++M) {
if (M->isInstanceMethod() == WantInstanceMethods) {
// Check whether the selector identifiers we've been given are a
// subset of the identifiers for this particular method.
- if (!isAcceptableObjCMethod(&*M, WantKind, SelIdents, NumSelIdents,
+ if (!isAcceptableObjCMethod(*M, WantKind, SelIdents, NumSelIdents,
AllowSameLength))
continue;
if (!Selectors.insert(M->getSelector()))
continue;
- Result R = Result(&*M, 0);
+ Result R = Result(*M, 0);
R.StartParameter = NumSelIdents;
R.AllParametersAreInformative = (WantKind != MK_Any);
if (!InOriginalClass)
@@ -5826,7 +5848,8 @@
return;
// Ignore any properties that have already been implemented.
- for (DeclContext::decl_iterator D = Container->decls_begin(),
+ Container = getContainerDef(Container);
+ for (DeclContext::decl_iterator D = Container->decls_begin(),
DEnd = Container->decls_end();
D != DEnd; ++D)
if (ObjCPropertyImplDecl *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(*D))
@@ -5959,9 +5982,12 @@
KnownMethodsMap &KnownMethods,
bool InOriginalClass = true) {
if (ObjCInterfaceDecl *IFace = dyn_cast<ObjCInterfaceDecl>(Container)) {
- // Recurse into protocols.
+ // Make sure we have a definition; that's what we'll walk.
if (!IFace->hasDefinition())
return;
+
+ IFace = IFace->getDefinition();
+ Container = IFace;
const ObjCList<ObjCProtocolDecl> &Protocols
= IFace->getReferencedProtocols();
@@ -6003,16 +6029,20 @@
}
if (ObjCProtocolDecl *Protocol = dyn_cast<ObjCProtocolDecl>(Container)) {
- if (Protocol->hasDefinition()) {
- // Recurse into protocols.
- const ObjCList<ObjCProtocolDecl> &Protocols
- = Protocol->getReferencedProtocols();
- for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
- E = Protocols.end();
- I != E; ++I)
- FindImplementableMethods(Context, *I, WantInstanceMethods, ReturnType,
- KnownMethods, false);
- }
+ // Make sure we have a definition; that's what we'll walk.
+ if (!Protocol->hasDefinition())
+ return;
+ Protocol = Protocol->getDefinition();
+ Container = Protocol;
+
+ // Recurse into protocols.
+ const ObjCList<ObjCProtocolDecl> &Protocols
+ = Protocol->getReferencedProtocols();
+ for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
+ E = Protocols.end();
+ I != E; ++I)
+ FindImplementableMethods(Context, *I, WantInstanceMethods, ReturnType,
+ KnownMethods, false);
}
// Add methods in this container. This operation occurs last because
@@ -6026,7 +6056,7 @@
!Context.hasSameUnqualifiedType(ReturnType, M->getResultType()))
continue;
- KnownMethods[M->getSelector()] = std::make_pair(&*M, InOriginalClass);
+ KnownMethods[M->getSelector()] = std::make_pair(*M, InOriginalClass);
}
}
}
@@ -6842,7 +6872,7 @@
for (ObjCContainerDecl::prop_iterator P = Containers[I]->prop_begin(),
PEnd = Containers[I]->prop_end();
P != PEnd; ++P) {
- AddObjCKeyValueCompletions(&*P, IsInstanceMethod, ReturnType, Context,
+ AddObjCKeyValueCompletions(*P, IsInstanceMethod, ReturnType, Context,
KnownSelectors, Results);
}
}
Modified: cfe/branches/tooling/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDecl.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDecl.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDecl.cpp Fri Jun 15 06:08:27 2012
@@ -2039,7 +2039,7 @@
<< New << getSpecialMember(OldMethod);
return true;
}
- } else if (OldMethod->isExplicitlyDefaulted()) {
+ } else if (OldMethod->isExplicitlyDefaulted() && !isFriend) {
Diag(NewMethod->getLocation(),
diag::err_definition_of_explicitly_defaulted_member)
<< getSpecialMember(OldMethod);
@@ -2969,7 +2969,7 @@
Context.getTypeDeclType(Record),
TInfo,
/*BitWidth=*/0, /*Mutable=*/false,
- /*HasInit=*/false);
+ /*InitStyle=*/ICIS_NoInit);
Anon->setAccess(AS);
if (getLangOpts().CPlusPlus)
FieldCollector->Add(cast<FieldDecl>(Anon));
@@ -3066,7 +3066,7 @@
Context.getTypeDeclType(Record),
TInfo,
/*BitWidth=*/0, /*Mutable=*/false,
- /*HasInit=*/false);
+ /*InitStyle=*/ICIS_NoInit);
Anon->setImplicit();
// Add the anonymous struct object to the current context.
@@ -4604,22 +4604,39 @@
// Also only accept corrections that have the same parent decl.
class DifferentNameValidatorCCC : public CorrectionCandidateCallback {
public:
- DifferentNameValidatorCCC(CXXRecordDecl *Parent)
- : ExpectedParent(Parent ? Parent->getCanonicalDecl() : 0) {}
+ DifferentNameValidatorCCC(ASTContext &Context, FunctionDecl *TypoFD,
+ CXXRecordDecl *Parent)
+ : Context(Context), OriginalFD(TypoFD),
+ ExpectedParent(Parent ? Parent->getCanonicalDecl() : 0) {}
virtual bool ValidateCandidate(const TypoCorrection &candidate) {
if (candidate.getEditDistance() == 0)
return false;
- if (CXXMethodDecl *MD = candidate.getCorrectionDeclAs<CXXMethodDecl>()) {
- CXXRecordDecl *Parent = MD->getParent();
- return Parent && Parent->getCanonicalDecl() == ExpectedParent;
+ llvm::SmallVector<unsigned, 1> MismatchedParams;
+ for (TypoCorrection::const_decl_iterator CDecl = candidate.begin(),
+ CDeclEnd = candidate.end();
+ CDecl != CDeclEnd; ++CDecl) {
+ FunctionDecl *FD = dyn_cast<FunctionDecl>(*CDecl);
+
+ if (FD && !FD->hasBody() &&
+ hasSimilarParameters(Context, FD, OriginalFD, MismatchedParams)) {
+ if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
+ CXXRecordDecl *Parent = MD->getParent();
+ if (Parent && Parent->getCanonicalDecl() == ExpectedParent)
+ return true;
+ } else if (!ExpectedParent) {
+ return true;
+ }
+ }
}
- return !ExpectedParent;
+ return false;
}
private:
+ ASTContext &Context;
+ FunctionDecl *OriginalFD;
CXXRecordDecl *ExpectedParent;
};
@@ -4655,7 +4672,8 @@
assert(!Prev.isAmbiguous() &&
"Cannot have an ambiguity in previous-declaration lookup");
CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewFD);
- DifferentNameValidatorCCC Validator(MD ? MD->getParent() : 0);
+ DifferentNameValidatorCCC Validator(SemaRef.Context, NewFD,
+ MD ? MD->getParent() : 0);
if (!Prev.empty()) {
for (LookupResult::iterator Func = Prev.begin(), FuncEnd = Prev.end();
Func != FuncEnd; ++Func) {
@@ -4685,8 +4703,8 @@
CDeclEnd = Correction.end();
CDecl != CDeclEnd; ++CDecl) {
FunctionDecl *FD = dyn_cast<FunctionDecl>(*CDecl);
- if (FD && hasSimilarParameters(SemaRef.Context, FD, NewFD,
- MismatchedParams)) {
+ if (FD && !FD->hasBody() &&
+ hasSimilarParameters(SemaRef.Context, FD, NewFD, MismatchedParams)) {
Previous.addDecl(FD);
}
}
@@ -4724,15 +4742,19 @@
}
}
- if (Correction)
- SemaRef.Diag(NewFD->getLocation(), DiagMsg)
+ if (Correction) {
+ SourceRange FixItLoc(NewFD->getLocation());
+ CXXScopeSpec &SS = ExtraArgs.D.getCXXScopeSpec();
+ if (Correction.getCorrectionSpecifier() && SS.isValid())
+ FixItLoc.setBegin(SS.getBeginLoc());
+ SemaRef.Diag(NewFD->getLocStart(), DiagMsg)
<< Name << NewDC << Correction.getQuoted(SemaRef.getLangOpts())
<< FixItHint::CreateReplacement(
- NewFD->getLocation(),
- Correction.getAsString(SemaRef.getLangOpts()));
- else
+ FixItLoc, Correction.getAsString(SemaRef.getLangOpts()));
+ } else {
SemaRef.Diag(NewFD->getLocation(), DiagMsg)
<< Name << NewDC << NewFD->getLocation();
+ }
bool NewFDisConst = false;
if (CXXMethodDecl *NewMD = dyn_cast<CXXMethodDecl>(NewFD))
@@ -5136,7 +5158,7 @@
QualType T = R->getAs<FunctionType>()->getResultType();
DeclaratorChunk &C = D.getTypeObject(0);
if (!T->isVoidType() && C.Fun.NumArgs == 0 && !C.Fun.isVariadic &&
- !C.Fun.TrailingReturnType &&
+ !C.Fun.hasTrailingReturnType() &&
C.Fun.getExceptionSpecType() == EST_None) {
SourceRange ParenRange(C.Loc, C.EndLoc);
Diag(C.Loc, diag::warn_empty_parens_are_function_decl) << ParenRange;
@@ -6281,6 +6303,17 @@
if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(VDecl))
VDecl->setInvalidDecl();
+ // Warn if we deduced 'id'. 'auto' usually implies type-safety, but using
+ // 'id' instead of a specific object type prevents most of our usual checks.
+ // We only want to warn outside of template instantiations, though:
+ // inside a template, the 'id' could have come from a parameter.
+ if (ActiveTemplateInstantiations.empty() &&
+ DeducedType->getType()->isObjCIdType()) {
+ SourceLocation Loc = DeducedType->getTypeLoc().getBeginLoc();
+ Diag(Loc, diag::warn_auto_var_is_id)
+ << VDecl->getDeclName() << DeduceInit->getSourceRange();
+ }
+
// If this is a redeclaration, check that the type we just deduced matches
// the previously declared type.
if (VarDecl *Old = VDecl->getPreviousDecl())
@@ -7443,7 +7476,7 @@
if (EnumDecl *ED = dyn_cast<EnumDecl>(D)) {
for (EnumDecl::enumerator_iterator EI = ED->enumerator_begin(),
EE = ED->enumerator_end(); EI != EE; ++EI)
- PushOnScopeChains(&*EI, FnBodyScope, /*AddToContext=*/false);
+ PushOnScopeChains(*EI, FnBodyScope, /*AddToContext=*/false);
}
}
}
@@ -8942,7 +8975,7 @@
Declarator &D, Expr *BitfieldWidth) {
FieldDecl *Res = HandleField(S, cast_or_null<RecordDecl>(TagD),
DeclStart, D, static_cast<Expr*>(BitfieldWidth),
- /*HasInit=*/false, AS_public);
+ /*InitStyle=*/ICIS_NoInit, AS_public);
return Res;
}
@@ -8950,7 +8983,8 @@
///
FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record,
SourceLocation DeclStart,
- Declarator &D, Expr *BitWidth, bool HasInit,
+ Declarator &D, Expr *BitWidth,
+ InClassInitStyle InitStyle,
AccessSpecifier AS) {
IdentifierInfo *II = D.getIdentifier();
SourceLocation Loc = DeclStart;
@@ -9012,7 +9046,7 @@
= (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_mutable);
SourceLocation TSSL = D.getLocStart();
FieldDecl *NewFD
- = CheckFieldDecl(II, T, TInfo, Record, Loc, Mutable, BitWidth, HasInit,
+ = CheckFieldDecl(II, T, TInfo, Record, Loc, Mutable, BitWidth, InitStyle,
TSSL, AS, PrevDecl, &D);
if (NewFD->isInvalidDecl())
@@ -9045,7 +9079,8 @@
FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, QualType T,
TypeSourceInfo *TInfo,
RecordDecl *Record, SourceLocation Loc,
- bool Mutable, Expr *BitWidth, bool HasInit,
+ bool Mutable, Expr *BitWidth,
+ InClassInitStyle InitStyle,
SourceLocation TSSL,
AccessSpecifier AS, NamedDecl *PrevDecl,
Declarator *D) {
@@ -9135,7 +9170,7 @@
}
FieldDecl *NewFD = FieldDecl::Create(Context, Record, TSSL, Loc, II, T, TInfo,
- BitWidth, Mutable, HasInit);
+ BitWidth, Mutable, InitStyle);
if (InvalidDecl)
NewFD->setInvalidDecl();
@@ -9271,7 +9306,7 @@
if (RD->hasUserDeclaredConstructor()) {
typedef CXXRecordDecl::ctor_iterator ctor_iter;
for (ctor_iter CI = RD->ctor_begin(), CE = RD->ctor_end(); CI != CE; ++CI)
- if (DiagnoseNontrivialUserProvidedCtor(*this, QT, &*CI, member))
+ if (DiagnoseNontrivialUserProvidedCtor(*this, QT, *CI, member))
return;
// No user-provided constructors; look for constructor templates.
Modified: cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp Fri Jun 15 06:08:27 2012
@@ -1610,7 +1610,7 @@
}
if (!isa<VarDecl>(D) && !isa<ObjCIvarDecl>(D) && !isFunctionOrMethod(D) &&
- !isa<TypeDecl>(D) && !isa<LabelDecl>(D)) {
+ !isa<TypeDecl>(D) && !isa<LabelDecl>(D) && !isa<FieldDecl>(D)) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
<< Attr.getName() << ExpectedVariableFunctionOrLabel;
return;
@@ -2835,7 +2835,7 @@
return;
}
- FieldDecl *FirstField = &*Field;
+ FieldDecl *FirstField = *Field;
QualType FirstType = FirstField->getType();
if (FirstType->hasFloatingRepresentation() || FirstType->isVectorType()) {
S.Diag(FirstField->getLocation(),
@@ -4237,7 +4237,7 @@
}
/// DeclClonePragmaWeak - clone existing decl (maybe definition),
-/// #pragma weak needs a non-definition decl and source may not have one
+/// \#pragma weak needs a non-definition decl and source may not have one.
NamedDecl * Sema::DeclClonePragmaWeak(NamedDecl *ND, IdentifierInfo *II,
SourceLocation Loc) {
assert(isa<FunctionDecl>(ND) || isa<VarDecl>(ND));
@@ -4287,7 +4287,7 @@
return NewD;
}
-/// DeclApplyPragmaWeak - A declaration (maybe definition) needs #pragma weak
+/// DeclApplyPragmaWeak - A declaration (maybe definition) needs \#pragma weak
/// applied to it, possibly with an alias.
void Sema::DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W) {
if (W.getUsed()) return; // only do this once
Modified: cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp Fri Jun 15 06:08:27 2012
@@ -23,6 +23,7 @@
#include "clang/AST/CharUnits.h"
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/DeclVisitor.h"
+#include "clang/AST/EvaluatedExprVisitor.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/RecordLayout.h"
#include "clang/AST/RecursiveASTVisitor.h"
@@ -833,8 +834,8 @@
I != E; ++I)
// If an anonymous union contains an anonymous struct of which any member
// is initialized, all members must be initialized.
- if (!RD->isUnion() || Inits.count(&*I))
- CheckConstexprCtorInitializer(SemaRef, Dcl, &*I, Inits, Diagnosed);
+ if (!RD->isUnion() || Inits.count(*I))
+ CheckConstexprCtorInitializer(SemaRef, Dcl, *I, Inits, Diagnosed);
}
}
@@ -943,7 +944,7 @@
bool Diagnosed = false;
for (CXXRecordDecl::field_iterator I = RD->field_begin(),
E = RD->field_end(); I != E; ++I)
- CheckConstexprCtorInitializer(*this, Dcl, &*I, Inits, Diagnosed);
+ CheckConstexprCtorInitializer(*this, Dcl, *I, Inits, Diagnosed);
if (Diagnosed)
return false;
}
@@ -1453,13 +1454,13 @@
/// ActOnCXXMemberDeclarator - This is invoked when a C++ class member
/// declarator is parsed. 'AS' is the access specifier, 'BW' specifies the
/// bitfield width if there is one, 'InitExpr' specifies the initializer if
-/// one has been parsed, and 'HasDeferredInit' is true if an initializer is
-/// present but parsing it has been deferred.
+/// one has been parsed, and 'InitStyle' is set if an in-class initializer is
+/// present (but parsing it has been deferred).
Decl *
Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
MultiTemplateParamsArg TemplateParameterLists,
Expr *BW, const VirtSpecifiers &VS,
- bool HasDeferredInit) {
+ InClassInitStyle InitStyle) {
const DeclSpec &DS = D.getDeclSpec();
DeclarationNameInfo NameInfo = GetNameForDeclarator(D);
DeclarationName Name = NameInfo.getName();
@@ -1563,10 +1564,10 @@
}
Member = HandleField(S, cast<CXXRecordDecl>(CurContext), Loc, D, BitWidth,
- HasDeferredInit, AS);
+ InitStyle, AS);
assert(Member && "HandleField never returns null");
} else {
- assert(!HasDeferredInit);
+ assert(InitStyle == ICIS_NoInit);
Member = HandleDeclarator(S, D, move(TemplateParameterLists));
if (!Member) {
@@ -1646,6 +1647,7 @@
// effects and are not part of a dependent type declaration.
if (!FD->isImplicit() && FD->getDeclName() &&
FD->getAccess() == AS_private &&
+ !FD->hasAttr<UnusedAttr>() &&
!FD->getParent()->getTypeForDecl()->isDependentType() &&
!InitializationHasSideEffects(*FD))
UnusedPrivateFields.insert(FD);
@@ -1660,9 +1662,11 @@
/// instantiating an in-class initializer in a class template. Such actions
/// are deferred until the class is complete.
void
-Sema::ActOnCXXInClassMemberInitializer(Decl *D, SourceLocation EqualLoc,
+Sema::ActOnCXXInClassMemberInitializer(Decl *D, SourceLocation InitLoc,
Expr *InitExpr) {
FieldDecl *FD = cast<FieldDecl>(D);
+ assert(FD->getInClassInitStyle() != ICIS_NoInit &&
+ "must set init style when field is created");
if (!InitExpr) {
FD->setInvalidDecl();
@@ -1685,9 +1689,9 @@
Expr **Inits = &InitExpr;
unsigned NumInits = 1;
InitializedEntity Entity = InitializedEntity::InitializeMember(FD);
- InitializationKind Kind = EqualLoc.isInvalid()
+ InitializationKind Kind = FD->getInClassInitStyle() == ICIS_ListInit
? InitializationKind::CreateDirectList(InitExpr->getLocStart())
- : InitializationKind::CreateCopy(InitExpr->getLocStart(), EqualLoc);
+ : InitializationKind::CreateCopy(InitExpr->getLocStart(), InitLoc);
InitializationSequence Seq(*this, Entity, Kind, Inits, NumInits);
Init = Seq.Perform(*this, Entity, Kind, MultiExprArg(Inits, NumInits));
if (Init.isInvalid()) {
@@ -1695,7 +1699,7 @@
return;
}
- CheckImplicitConversions(Init.get(), EqualLoc);
+ CheckImplicitConversions(Init.get(), InitLoc);
}
// C++0x [class.base.init]p7:
@@ -2035,73 +2039,95 @@
<< (unsigned)IsPointer;
}
-/// Checks an initializer expression for use of uninitialized fields, such as
-/// containing the field that is being initialized. Returns true if there is an
-/// uninitialized field was used an updates the SourceLocation parameter; false
-/// otherwise.
-static bool InitExprContainsUninitializedFields(const Stmt *S,
- const ValueDecl *LhsField,
- SourceLocation *L) {
- assert(isa<FieldDecl>(LhsField) || isa<IndirectFieldDecl>(LhsField));
-
- if (isa<CallExpr>(S)) {
- // Do not descend into function calls or constructors, as the use
- // of an uninitialized field may be valid. One would have to inspect
- // the contents of the function/ctor to determine if it is safe or not.
- // i.e. Pass-by-value is never safe, but pass-by-reference and pointers
- // may be safe, depending on what the function/ctor does.
- return false;
- }
- if (const MemberExpr *ME = dyn_cast<MemberExpr>(S)) {
- const NamedDecl *RhsField = ME->getMemberDecl();
-
- if (const VarDecl *VD = dyn_cast<VarDecl>(RhsField)) {
- // The member expression points to a static data member.
- assert(VD->isStaticDataMember() &&
- "Member points to non-static data member!");
- (void)VD;
- return false;
- }
-
- if (isa<EnumConstantDecl>(RhsField)) {
- // The member expression points to an enum.
- return false;
- }
+namespace {
+ class UninitializedFieldVisitor
+ : public EvaluatedExprVisitor<UninitializedFieldVisitor> {
+ Sema &S;
+ ValueDecl *VD;
+ public:
+ typedef EvaluatedExprVisitor<UninitializedFieldVisitor> Inherited;
+ UninitializedFieldVisitor(Sema &S, ValueDecl *VD) : Inherited(S.Context),
+ S(S), VD(VD) {
+ }
+
+ void HandleExpr(Expr *E) {
+ if (!E) return;
+
+ // Expressions like x(x) sometimes lack the surrounding expressions
+ // but need to be checked anyways.
+ HandleValue(E);
+ Visit(E);
+ }
+
+ void HandleValue(Expr *E) {
+ E = E->IgnoreParens();
+
+ if (MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
+ if (isa<EnumConstantDecl>(ME->getMemberDecl()))
+ return;
+ Expr *Base = E;
+ while (isa<MemberExpr>(Base)) {
+ ME = dyn_cast<MemberExpr>(Base);
+ if (VarDecl *VarD = dyn_cast<VarDecl>(ME->getMemberDecl()))
+ if (VarD->hasGlobalStorage())
+ return;
+ Base = ME->getBase();
+ }
- if (RhsField == LhsField) {
- // Initializing a field with itself. Throw a warning.
- // But wait; there are exceptions!
- // Exception #1: The field may not belong to this record.
- // e.g. Foo(const Foo& rhs) : A(rhs.A) {}
- const Expr *base = ME->getBase();
- if (base != NULL && !isa<CXXThisExpr>(base->IgnoreParenCasts())) {
- // Even though the field matches, it does not belong to this record.
- return false;
+ if (VD == ME->getMemberDecl() && isa<CXXThisExpr>(Base)) {
+ S.Diag(ME->getExprLoc(), diag::warn_field_is_uninit);
+ return;
+ }
+ }
+
+ if (ConditionalOperator *CO = dyn_cast<ConditionalOperator>(E)) {
+ HandleValue(CO->getTrueExpr());
+ HandleValue(CO->getFalseExpr());
+ return;
+ }
+
+ if (BinaryConditionalOperator *BCO =
+ dyn_cast<BinaryConditionalOperator>(E)) {
+ HandleValue(BCO->getCommon());
+ HandleValue(BCO->getFalseExpr());
+ return;
+ }
+
+ if (BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
+ switch (BO->getOpcode()) {
+ default:
+ return;
+ case(BO_PtrMemD):
+ case(BO_PtrMemI):
+ HandleValue(BO->getLHS());
+ return;
+ case(BO_Comma):
+ HandleValue(BO->getRHS());
+ return;
+ }
}
- // None of the exceptions triggered; return true to indicate an
- // uninitialized field was used.
- *L = ME->getMemberLoc();
- return true;
}
- } else if (isa<UnaryExprOrTypeTraitExpr>(S)) {
- // sizeof/alignof doesn't reference contents, do not warn.
- return false;
- } else if (const UnaryOperator *UOE = dyn_cast<UnaryOperator>(S)) {
- // address-of doesn't reference contents (the pointer may be dereferenced
- // in the same expression but it would be rare; and weird).
- if (UOE->getOpcode() == UO_AddrOf)
- return false;
- }
- for (Stmt::const_child_range it = S->children(); it; ++it) {
- if (!*it) {
- // An expression such as 'member(arg ?: "")' may trigger this.
- continue;
+
+ void VisitImplicitCastExpr(ImplicitCastExpr *E) {
+ if (E->getCastKind() == CK_LValueToRValue)
+ HandleValue(E->getSubExpr());
+
+ Inherited::VisitImplicitCastExpr(E);
}
- if (InitExprContainsUninitializedFields(*it, LhsField, L))
- return true;
+
+ void VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
+ Expr *Callee = E->getCallee();
+ if (isa<MemberExpr>(Callee))
+ HandleValue(Callee);
+
+ Inherited::VisitCXXMemberCallExpr(E);
+ }
+ };
+ static void CheckInitExprContainsUninitializedFields(Sema &S, Expr *E,
+ ValueDecl *VD) {
+ UninitializedFieldVisitor(S, VD).HandleExpr(E);
}
- return false;
-}
+} // namespace
MemInitResult
Sema::BuildMemberInitializer(ValueDecl *Member, Expr *Init,
@@ -2150,18 +2176,16 @@
}
}
- for (unsigned i = 0; i < NumArgs; ++i) {
- SourceLocation L;
- if (InitExprContainsUninitializedFields(Args[i], Member, &L)) {
- // FIXME: Return true in the case when other fields are used before being
+ if (getDiagnostics().getDiagnosticLevel(diag::warn_field_is_uninit, IdLoc)
+ != DiagnosticsEngine::Ignored)
+ for (unsigned i = 0; i < NumArgs; ++i)
+ // FIXME: Warn about the case when other fields are used before being
// uninitialized. For example, let this field be the i'th field. When
// initializing the i'th field, throw a warning if any of the >= i'th
// fields are used, as they are not yet initialized.
// Right now we are only handling the case where the i'th field uses
// itself in its initializer.
- Diag(L, diag::warn_field_is_uninit);
- }
- }
+ CheckInitExprContainsUninitializedFields(*this, Args[i], Member);
SourceRange InitRange = Init->getSourceRange();
@@ -3150,7 +3174,7 @@
if (Field->isUnnamedBitfield())
continue;
- IdealInitKeys.push_back(GetKeyForTopLevelField(&*Field));
+ IdealInitKeys.push_back(GetKeyForTopLevelField(*Field));
}
unsigned NumIdealInits = IdealInitKeys.size();
@@ -3350,7 +3374,7 @@
// Non-static data members.
for (CXXRecordDecl::field_iterator I = ClassDecl->field_begin(),
E = ClassDecl->field_end(); I != E; ++I) {
- FieldDecl *Field = &*I;
+ FieldDecl *Field = *I;
if (Field->isInvalidDecl())
continue;
@@ -3807,7 +3831,7 @@
MEnd = Record->method_end();
M != MEnd; ++M) {
if (!M->isStatic())
- DiagnoseHiddenVirtualMethods(Record, &*M);
+ DiagnoseHiddenVirtualMethods(Record, *M);
}
}
@@ -3865,7 +3889,102 @@
ME = Record->method_end();
MI != ME; ++MI)
if (!MI->isInvalidDecl() && MI->isExplicitlyDefaulted())
- CheckExplicitlyDefaultedSpecialMember(&*MI);
+ CheckExplicitlyDefaultedSpecialMember(*MI);
+}
+
+/// Is the special member function which would be selected to perform the
+/// specified operation on the specified class type a constexpr constructor?
+static bool specialMemberIsConstexpr(Sema &S, CXXRecordDecl *ClassDecl,
+ Sema::CXXSpecialMember CSM,
+ bool ConstArg) {
+ Sema::SpecialMemberOverloadResult *SMOR =
+ S.LookupSpecialMember(ClassDecl, CSM, ConstArg,
+ false, false, false, false);
+ if (!SMOR || !SMOR->getMethod())
+ // A constructor we wouldn't select can't be "involved in initializing"
+ // anything.
+ return true;
+ return SMOR->getMethod()->isConstexpr();
+}
+
+/// Determine whether the specified special member function would be constexpr
+/// if it were implicitly defined.
+static bool defaultedSpecialMemberIsConstexpr(Sema &S, CXXRecordDecl *ClassDecl,
+ Sema::CXXSpecialMember CSM,
+ bool ConstArg) {
+ if (!S.getLangOpts().CPlusPlus0x)
+ return false;
+
+ // C++11 [dcl.constexpr]p4:
+ // In the definition of a constexpr constructor [...]
+ switch (CSM) {
+ case Sema::CXXDefaultConstructor:
+ // Since default constructor lookup is essentially trivial (and cannot
+ // involve, for instance, template instantiation), we compute whether a
+ // defaulted default constructor is constexpr directly within CXXRecordDecl.
+ //
+ // This is important for performance; we need to know whether the default
+ // constructor is constexpr to determine whether the type is a literal type.
+ return ClassDecl->defaultedDefaultConstructorIsConstexpr();
+
+ case Sema::CXXCopyConstructor:
+ case Sema::CXXMoveConstructor:
+ // For copy or move constructors, we need to perform overload resolution.
+ break;
+
+ case Sema::CXXCopyAssignment:
+ case Sema::CXXMoveAssignment:
+ case Sema::CXXDestructor:
+ case Sema::CXXInvalid:
+ return false;
+ }
+
+ // -- if the class is a non-empty union, or for each non-empty anonymous
+ // union member of a non-union class, exactly one non-static data member
+ // shall be initialized; [DR1359]
+ //
+ // If we squint, this is guaranteed, since exactly one non-static data member
+ // will be initialized (if the constructor isn't deleted), we just don't know
+ // which one.
+ if (ClassDecl->isUnion())
+ return true;
+
+ // -- the class shall not have any virtual base classes;
+ if (ClassDecl->getNumVBases())
+ return false;
+
+ // -- every constructor involved in initializing [...] base class
+ // sub-objects shall be a constexpr constructor;
+ for (CXXRecordDecl::base_class_iterator B = ClassDecl->bases_begin(),
+ BEnd = ClassDecl->bases_end();
+ B != BEnd; ++B) {
+ const RecordType *BaseType = B->getType()->getAs<RecordType>();
+ if (!BaseType) continue;
+
+ CXXRecordDecl *BaseClassDecl = cast<CXXRecordDecl>(BaseType->getDecl());
+ if (!specialMemberIsConstexpr(S, BaseClassDecl, CSM, ConstArg))
+ return false;
+ }
+
+ // -- every constructor involved in initializing non-static data members
+ // [...] shall be a constexpr constructor;
+ // -- every non-static data member and base class sub-object shall be
+ // initialized
+ for (RecordDecl::field_iterator F = ClassDecl->field_begin(),
+ FEnd = ClassDecl->field_end();
+ F != FEnd; ++F) {
+ if (F->isInvalidDecl())
+ continue;
+ if (const RecordType *RecordTy =
+ S.Context.getBaseElementType(F->getType())->getAs<RecordType>()) {
+ CXXRecordDecl *FieldRecDecl = cast<CXXRecordDecl>(RecordTy->getDecl());
+ if (!specialMemberIsConstexpr(S, FieldRecDecl, CSM, ConstArg))
+ return false;
+ }
+ }
+
+ // All OK, it's constexpr!
+ return true;
}
void Sema::CheckExplicitlyDefaultedSpecialMember(CXXMethodDecl *MD) {
@@ -3905,8 +4024,7 @@
// Compute implicit exception specification, argument constness, constexpr
// and triviality.
ImplicitExceptionSpecification Spec(*this);
- bool Const = false;
- bool Constexpr = false;
+ bool CanHaveConstParam = false;
bool Trivial;
switch (CSM) {
case CXXDefaultConstructor:
@@ -3915,23 +4033,20 @@
// Exception specification depends on some deferred part of the class.
// We'll try again when the class's definition has been fully processed.
return;
- Constexpr = RD->defaultedDefaultConstructorIsConstexpr();
Trivial = RD->hasTrivialDefaultConstructor();
break;
case CXXCopyConstructor:
- llvm::tie(Spec, Const) =
+ llvm::tie(Spec, CanHaveConstParam) =
ComputeDefaultedCopyCtorExceptionSpecAndConst(RD);
- Constexpr = RD->defaultedCopyConstructorIsConstexpr();
Trivial = RD->hasTrivialCopyConstructor();
break;
case CXXCopyAssignment:
- llvm::tie(Spec, Const) =
+ llvm::tie(Spec, CanHaveConstParam) =
ComputeDefaultedCopyAssignmentExceptionSpecAndConst(RD);
Trivial = RD->hasTrivialCopyAssignment();
break;
case CXXMoveConstructor:
Spec = ComputeDefaultedMoveCtorExceptionSpec(RD);
- Constexpr = RD->defaultedMoveConstructorIsConstexpr();
Trivial = RD->hasTrivialMoveConstructor();
break;
case CXXMoveAssignment:
@@ -3968,9 +4083,11 @@
// Check for parameter type matching.
QualType ArgType = ExpectedParams ? Type->getArgType(0) : QualType();
+ bool HasConstParam = false;
if (ExpectedParams && ArgType->isReferenceType()) {
// Argument must be reference to possibly-const T.
QualType ReferentType = ArgType->getPointeeType();
+ HasConstParam = ReferentType.isConstQualified();
if (ReferentType.isVolatileQualified()) {
Diag(MD->getLocation(),
@@ -3978,7 +4095,7 @@
HadError = true;
}
- if (ReferentType.isConstQualified() && !Const) {
+ if (HasConstParam && !CanHaveConstParam) {
if (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment) {
Diag(MD->getLocation(),
diag::err_defaulted_special_member_copy_const_param)
@@ -3995,7 +4112,7 @@
// If a function is explicitly defaulted on its first declaration, it shall
// have the same parameter type as if it had been implicitly declared.
// (Presumably this is to prevent it from being trivial?)
- if (!ReferentType.isConstQualified() && Const && First)
+ if (!HasConstParam && CanHaveConstParam && First)
Diag(MD->getLocation(),
diag::err_defaulted_special_member_copy_non_const_param)
<< (CSM == CXXCopyAssignment);
@@ -4019,9 +4136,12 @@
// Do not apply this rule to members of class templates, since core issue 1358
// makes such functions always instantiate to constexpr functions. For
// non-constructors, this is checked elsewhere.
+ bool Constexpr = defaultedSpecialMemberIsConstexpr(*this, RD, CSM,
+ HasConstParam);
if (isa<CXXConstructorDecl>(MD) && MD->isConstexpr() && !Constexpr &&
MD->getTemplatedKind() == FunctionDecl::TK_NonTemplate) {
Diag(MD->getLocStart(), diag::err_incorrect_defaulted_constexpr) << CSM;
+ // FIXME: Explain why the constructor can't be constexpr.
HadError = true;
}
// and may have an explicit exception-specification only if it is compatible
@@ -4327,7 +4447,7 @@
CXXRecordDecl *UnionFieldRecord = UnionFieldType->getAsCXXRecordDecl();
if (UnionFieldRecord &&
- shouldDeleteForClassSubobject(UnionFieldRecord, &*UI))
+ shouldDeleteForClassSubobject(UnionFieldRecord, *UI))
return true;
}
@@ -4464,7 +4584,7 @@
for (CXXRecordDecl::field_iterator FI = RD->field_begin(),
FE = RD->field_end(); FI != FE; ++FI)
if (!FI->isInvalidDecl() && !FI->isUnnamedBitfield() &&
- SMI.shouldDeleteForField(&*FI))
+ SMI.shouldDeleteForField(*FI))
return true;
if (SMI.shouldDeleteForAllConstMembers())
@@ -6624,6 +6744,10 @@
ComputeDefaultedDefaultCtorExceptionSpec(ClassDecl);
FunctionProtoType::ExtProtoInfo EPI = Spec.getEPI();
+ bool Constexpr = defaultedSpecialMemberIsConstexpr(*this, ClassDecl,
+ CXXDefaultConstructor,
+ false);
+
// Create the actual constructor declaration.
CanQualType ClassType
= Context.getCanonicalType(Context.getTypeDeclType(ClassDecl));
@@ -6635,8 +6759,7 @@
Context, ClassDecl, ClassLoc, NameInfo,
Context.getFunctionType(Context.VoidTy, 0, 0, EPI), /*TInfo=*/0,
/*isExplicit=*/false, /*isInline=*/true, /*isImplicitlyDeclared=*/true,
- /*isConstexpr=*/ClassDecl->defaultedDefaultConstructorIsConstexpr() &&
- getLangOpts().CPlusPlus0x);
+ Constexpr);
DefaultCon->setAccess(AS_public);
DefaultCon->setDefaulted();
DefaultCon->setImplicit();
@@ -6816,7 +6939,7 @@
// results from omitting any ellipsis parameter specification and
// successively omitting parameters with a default argument from the
// end of the parameter-type-list.
- CXXConstructorDecl *BaseCtor = &*CtorIt;
+ CXXConstructorDecl *BaseCtor = *CtorIt;
bool CanBeCopyOrMove = BaseCtor->isCopyOrMoveConstructor();
const FunctionProtoType *BaseCtorType =
BaseCtor->getType()->getAs<FunctionProtoType>();
@@ -7647,7 +7770,7 @@
CXXScopeSpec SS; // Intentionally empty
LookupResult MemberLookup(*this, Field->getDeclName(), Loc,
LookupMemberName);
- MemberLookup.addDecl(&*Field);
+ MemberLookup.addDecl(*Field);
MemberLookup.resolveKind();
ExprResult From = BuildMemberReferenceExpr(OtherRef, OtherRefType,
Loc, /*IsArrow=*/false,
@@ -8182,7 +8305,7 @@
CXXScopeSpec SS; // Intentionally empty
LookupResult MemberLookup(*this, Field->getDeclName(), Loc,
LookupMemberName);
- MemberLookup.addDecl(&*Field);
+ MemberLookup.addDecl(*Field);
MemberLookup.resolveKind();
ExprResult From = BuildMemberReferenceExpr(OtherRef, OtherRefType,
Loc, /*IsArrow=*/false,
@@ -8472,6 +8595,10 @@
FunctionProtoType::ExtProtoInfo EPI = Spec.getEPI();
+ bool Constexpr = defaultedSpecialMemberIsConstexpr(*this, ClassDecl,
+ CXXCopyConstructor,
+ Const);
+
DeclarationName Name
= Context.DeclarationNames.getCXXConstructorName(
Context.getCanonicalType(ClassType));
@@ -8484,8 +8611,7 @@
Context, ClassDecl, ClassLoc, NameInfo,
Context.getFunctionType(Context.VoidTy, &ArgType, 1, EPI), /*TInfo=*/0,
/*isExplicit=*/false, /*isInline=*/true, /*isImplicitlyDeclared=*/true,
- /*isConstexpr=*/ClassDecl->defaultedCopyConstructorIsConstexpr() &&
- getLangOpts().CPlusPlus0x);
+ Constexpr);
CopyConstructor->setAccess(AS_public);
CopyConstructor->setDefaulted();
CopyConstructor->setTrivial(ClassDecl->hasTrivialCopyConstructor());
@@ -8642,6 +8768,10 @@
FunctionProtoType::ExtProtoInfo EPI = Spec.getEPI();
+ bool Constexpr = defaultedSpecialMemberIsConstexpr(*this, ClassDecl,
+ CXXMoveConstructor,
+ false);
+
DeclarationName Name
= Context.DeclarationNames.getCXXConstructorName(
Context.getCanonicalType(ClassType));
@@ -8655,8 +8785,7 @@
Context, ClassDecl, ClassLoc, NameInfo,
Context.getFunctionType(Context.VoidTy, &ArgType, 1, EPI), /*TInfo=*/0,
/*isExplicit=*/false, /*isInline=*/true, /*isImplicitlyDeclared=*/true,
- /*isConstexpr=*/ClassDecl->defaultedMoveConstructorIsConstexpr() &&
- getLangOpts().CPlusPlus0x);
+ Constexpr);
MoveConstructor->setAccess(AS_public);
MoveConstructor->setDefaulted();
MoveConstructor->setTrivial(ClassDecl->hasTrivialMoveConstructor());
@@ -10667,7 +10796,7 @@
const CXXRecordDecl *RD) {
for (CXXRecordDecl::method_iterator i = RD->method_begin(),
e = RD->method_end(); i != e; ++i) {
- CXXMethodDecl *MD = &*i;
+ CXXMethodDecl *MD = *i;
// C++ [basic.def.odr]p2:
// [...] A virtual member function is used if it is not pure. [...]
Modified: cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp Fri Jun 15 06:08:27 2012
@@ -503,7 +503,7 @@
}
/// ActOnCompatiblityAlias - this action is called after complete parsing of
-/// @compatibility_alias declaration. It sets up the alias relationships.
+/// a \@compatibility_alias declaration. It sets up the alias relationships.
Decl *Sema::ActOnCompatiblityAlias(SourceLocation AtLoc,
IdentifierInfo *AliasName,
SourceLocation AliasLocation,
@@ -695,7 +695,7 @@
llvm::DenseMap<Selector, const ObjCMethodDecl*> MethodMap;
for (ObjCInterfaceDecl::method_iterator i = ID->meth_begin(),
e = ID->meth_end(); i != e; ++i) {
- ObjCMethodDecl *MD = &*i;
+ ObjCMethodDecl *MD = *i;
MethodMap[MD->getSelector()] = MD;
}
@@ -703,7 +703,7 @@
return;
for (ObjCCategoryDecl::method_iterator i = CAT->meth_begin(),
e = CAT->meth_end(); i != e; ++i) {
- ObjCMethodDecl *Method = &*i;
+ ObjCMethodDecl *Method = *i;
const ObjCMethodDecl *&PrevMethod = MethodMap[Method->getSelector()];
if (PrevMethod && !MatchTwoMethodDeclarations(Method, PrevMethod)) {
Diag(Method->getLocation(), diag::err_duplicate_method_decl)
@@ -713,7 +713,7 @@
}
}
-/// ActOnForwardProtocolDeclaration - Handle @protocol foo;
+/// ActOnForwardProtocolDeclaration - Handle \@protocol foo;
Sema::DeclGroupPtrTy
Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc,
const IdentifierLocPair *IdentList,
@@ -1020,8 +1020,8 @@
ObjCInterfaceDecl* IDecl = ImpDecl->getClassInterface();
if (!IDecl)
return;
- /// Check case of non-existing @interface decl.
- /// (legacy objective-c @implementation decl without an @interface decl).
+ /// Check case of non-existing \@interface decl.
+ /// (legacy objective-c \@implementation decl without an \@interface decl).
/// Add implementations's ivar to the synthesize class's ivar list.
if (IDecl->isImplicitInterfaceDecl()) {
IDecl->setEndOfDefinitionLoc(RBrace);
@@ -1065,7 +1065,7 @@
IVI = IDecl->ivar_begin(), IVE = IDecl->ivar_end();
for (; numIvars > 0 && IVI != IVE; ++IVI) {
ObjCIvarDecl* ImplIvar = ivars[j++];
- ObjCIvarDecl* ClsIvar = &*IVI;
+ ObjCIvarDecl* ClsIvar = *IVI;
assert (ImplIvar && "missing implementation ivar");
assert (ClsIvar && "missing class ivar");
@@ -2147,14 +2147,14 @@
/// DiagnoseDuplicateIvars -
/// Check for duplicate ivars in the entire class at the start of
-/// @implementation. This becomes necesssary because class extension can
+/// \@implementation. This becomes necesssary because class extension can
/// add ivars to a class in random order which will not be known until
-/// class's @implementation is seen.
+/// class's \@implementation is seen.
void Sema::DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID,
ObjCInterfaceDecl *SID) {
for (ObjCInterfaceDecl::ivar_iterator IVI = ID->ivar_begin(),
IVE = ID->ivar_end(); IVI != IVE; ++IVI) {
- ObjCIvarDecl* Ivar = &*IVI;
+ ObjCIvarDecl* Ivar = *IVI;
if (Ivar->isInvalidDecl())
continue;
if (IdentifierInfo *II = Ivar->getIdentifier()) {
@@ -2292,7 +2292,7 @@
for (ObjCContainerDecl::prop_iterator I = CDecl->prop_begin(),
E = CDecl->prop_end();
I != E; ++I)
- ProcessPropertyDecl(&*I, CDecl);
+ ProcessPropertyDecl(*I, CDecl);
CDecl->setAtEndRange(AtEnd);
}
if (ObjCImplementationDecl *IC=dyn_cast<ObjCImplementationDecl>(ClassDecl)) {
@@ -2308,7 +2308,7 @@
ClsExtDecl; ClsExtDecl = ClsExtDecl->getNextClassExtension()) {
for (ObjCContainerDecl::prop_iterator I = ClsExtDecl->prop_begin(),
E = ClsExtDecl->prop_end(); I != E; ++I) {
- ObjCPropertyDecl *Property = &*I;
+ ObjCPropertyDecl *Property = *I;
// Skip over properties declared @dynamic
if (const ObjCPropertyImplDecl *PIDecl
= IC->FindPropertyImplDecl(Property->getIdentifier()))
@@ -2947,7 +2947,7 @@
return true;
}
-/// Called whenever @defs(ClassName) is encountered in the source. Inserts the
+/// Called whenever \@defs(ClassName) is encountered in the source. Inserts the
/// instance variables of ClassName into Decls.
void Sema::ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart,
IdentifierInfo *ClassName,
Modified: cfe/branches/tooling/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExpr.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExpr.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExpr.cpp Fri Jun 15 06:08:27 2012
@@ -2605,7 +2605,7 @@
llvm::APSInt Value(CharBits, CharIsUnsigned);
for (unsigned I = 0, N = Literal.getUDSuffixOffset(); I != N; ++I) {
Value = ThisTokBegin[I];
- TemplateArgument Arg(Value, Context.CharTy);
+ TemplateArgument Arg(Context, Value, Context.CharTy);
TemplateArgumentLocInfo ArgInfo;
ExplicitArgs.addArgument(TemplateArgumentLoc(Arg, ArgInfo));
}
@@ -5706,7 +5706,7 @@
if (RHSType->isPointerType())
if (RHSType->castAs<PointerType>()->getPointeeType()->isVoidType()) {
RHS = ImpCastExprToType(RHS.take(), it->getType(), CK_BitCast);
- InitField = &*it;
+ InitField = *it;
break;
}
@@ -5714,7 +5714,7 @@
Expr::NPC_ValueDependentIsNull)) {
RHS = ImpCastExprToType(RHS.take(), it->getType(),
CK_NullToPointer);
- InitField = &*it;
+ InitField = *it;
break;
}
}
@@ -5723,7 +5723,7 @@
if (CheckAssignmentConstraints(it->getType(), RHS, Kind)
== Compatible) {
RHS = ImpCastExprToType(RHS.take(), it->getType(), Kind);
- InitField = &*it;
+ InitField = *it;
break;
}
}
@@ -6589,6 +6589,153 @@
<< LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
}
+static bool isObjCObjectLiteral(ExprResult &E) {
+ switch (E.get()->getStmtClass()) {
+ case Stmt::ObjCArrayLiteralClass:
+ case Stmt::ObjCDictionaryLiteralClass:
+ case Stmt::ObjCStringLiteralClass:
+ case Stmt::ObjCBoxedExprClass:
+ return true;
+ default:
+ // Note that ObjCBoolLiteral is NOT an object literal!
+ return false;
+ }
+}
+
+static DiagnosticBuilder diagnoseObjCLiteralComparison(Sema &S,
+ SourceLocation Loc,
+ ExprResult &LHS,
+ ExprResult &RHS,
+ bool CanFix = false) {
+ Expr *Literal = (isObjCObjectLiteral(LHS) ? LHS : RHS).get();
+
+ unsigned LiteralKind;
+ switch (Literal->getStmtClass()) {
+ case Stmt::ObjCStringLiteralClass:
+ // "string literal"
+ LiteralKind = 0;
+ break;
+ case Stmt::ObjCArrayLiteralClass:
+ // "array literal"
+ LiteralKind = 1;
+ break;
+ case Stmt::ObjCDictionaryLiteralClass:
+ // "dictionary literal"
+ LiteralKind = 2;
+ break;
+ case Stmt::ObjCBoxedExprClass: {
+ Expr *Inner = cast<ObjCBoxedExpr>(Literal)->getSubExpr();
+ switch (Inner->getStmtClass()) {
+ case Stmt::IntegerLiteralClass:
+ case Stmt::FloatingLiteralClass:
+ case Stmt::CharacterLiteralClass:
+ case Stmt::ObjCBoolLiteralExprClass:
+ case Stmt::CXXBoolLiteralExprClass:
+ // "numeric literal"
+ LiteralKind = 3;
+ break;
+ case Stmt::ImplicitCastExprClass: {
+ CastKind CK = cast<CastExpr>(Inner)->getCastKind();
+ // Boolean literals can be represented by implicit casts.
+ if (CK == CK_IntegralToBoolean || CK == CK_IntegralCast) {
+ LiteralKind = 3;
+ break;
+ }
+ // FALLTHROUGH
+ }
+ default:
+ // "boxed expression"
+ LiteralKind = 4;
+ break;
+ }
+ break;
+ }
+ default:
+ llvm_unreachable("Unknown Objective-C object literal kind");
+ }
+
+ return S.Diag(Loc, diag::err_objc_literal_comparison)
+ << LiteralKind << CanFix << Literal->getSourceRange();
+}
+
+static ExprResult fixObjCLiteralComparison(Sema &S, SourceLocation OpLoc,
+ ExprResult &LHS,
+ ExprResult &RHS,
+ BinaryOperatorKind Op) {
+ assert((Op == BO_EQ || Op == BO_NE) && "Cannot fix other operations.");
+
+ // Get the LHS object's interface type.
+ QualType Type = LHS.get()->getType();
+ QualType InterfaceType;
+ if (const ObjCObjectPointerType *PTy = Type->getAs<ObjCObjectPointerType>()) {
+ InterfaceType = PTy->getPointeeType();
+ if (const ObjCObjectType *iQFaceTy =
+ InterfaceType->getAsObjCQualifiedInterfaceType())
+ InterfaceType = iQFaceTy->getBaseType();
+ } else {
+ // If this is not actually an Objective-C object, bail out.
+ return ExprEmpty();
+ }
+
+ // If the RHS isn't an Objective-C object, bail out.
+ if (!RHS.get()->getType()->isObjCObjectPointerType())
+ return ExprEmpty();
+
+ // Try to find the -isEqual: method.
+ Selector IsEqualSel = S.NSAPIObj->getIsEqualSelector();
+ ObjCMethodDecl *Method = S.LookupMethodInObjectType(IsEqualSel,
+ InterfaceType,
+ /*instance=*/true);
+ bool ReceiverIsId = (Type->isObjCIdType() || Type->isObjCQualifiedIdType());
+
+ if (!Method && ReceiverIsId) {
+ Method = S.LookupInstanceMethodInGlobalPool(IsEqualSel, SourceRange(),
+ /*receiverId=*/true,
+ /*warn=*/false);
+ }
+
+ if (!Method)
+ return ExprEmpty();
+
+ QualType T = Method->param_begin()[0]->getType();
+ if (!T->isObjCObjectPointerType())
+ return ExprEmpty();
+
+ QualType R = Method->getResultType();
+ if (!R->isScalarType())
+ return ExprEmpty();
+
+ // At this point we know we have a good -isEqual: method.
+ // Emit the diagnostic and fixit.
+ DiagnosticBuilder Diag = diagnoseObjCLiteralComparison(S, OpLoc,
+ LHS, RHS, true);
+
+ Expr *LHSExpr = LHS.take();
+ Expr *RHSExpr = RHS.take();
+
+ SourceLocation Start = LHSExpr->getLocStart();
+ SourceLocation End = S.PP.getLocForEndOfToken(RHSExpr->getLocEnd());
+ SourceRange OpRange(OpLoc, S.PP.getLocForEndOfToken(OpLoc));
+
+ Diag << FixItHint::CreateInsertion(Start, Op == BO_EQ ? "[" : "![")
+ << FixItHint::CreateReplacement(OpRange, "isEqual:")
+ << FixItHint::CreateInsertion(End, "]");
+
+ // Finally, build the call to -isEqual: (and possible logical not).
+ ExprResult Call = S.BuildInstanceMessage(LHSExpr, LHSExpr->getType(),
+ /*SuperLoc=*/SourceLocation(),
+ IsEqualSel, Method,
+ OpLoc, OpLoc, OpLoc,
+ MultiExprArg(S, &RHSExpr, 1),
+ /*isImplicit=*/false);
+
+ ExprResult CallCond = S.CheckBooleanCondition(Call.get(), OpLoc);
+
+ if (Op == BO_NE)
+ return S.CreateBuiltinUnaryOp(OpLoc, UO_LNot, CallCond.get());
+ return CallCond;
+}
+
// C99 6.5.8, C++ [expr.rel]
QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
SourceLocation Loc, unsigned OpaqueOpc,
@@ -6913,6 +7060,9 @@
if (!Context.areComparableObjCPointerTypes(LHSType, RHSType))
diagnoseDistinctPointerComparison(*this, Loc, LHS, RHS,
/*isError*/false);
+ if (isObjCObjectLiteral(LHS) || isObjCObjectLiteral(RHS))
+ diagnoseObjCLiteralComparison(*this, Loc, LHS, RHS);
+
if (LHSIsNull && !RHSIsNull)
LHS = ImpCastExprToType(LHS.take(), RHSType, CK_BitCast);
else
@@ -7971,6 +8121,13 @@
break;
case BO_EQ:
case BO_NE:
+ if (isObjCObjectLiteral(LHS) || isObjCObjectLiteral(RHS)) {
+ ExprResult IsEqualCall = fixObjCLiteralComparison(*this, OpLoc,
+ LHS, RHS, Opc);
+ if (IsEqualCall.isUsable())
+ return IsEqualCall;
+ // Otherwise, fall back to the normal diagnostic in CheckCompareOperands.
+ }
ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc, false);
break;
case BO_And:
@@ -10049,7 +10206,7 @@
FieldDecl *Field
= FieldDecl::Create(S.Context, Lambda, Loc, Loc, 0, FieldType,
S.Context.getTrivialTypeSourceInfo(FieldType, Loc),
- 0, false, false);
+ 0, false, ICIS_NoInit);
Field->setImplicit(true);
Field->setAccess(AS_private);
Lambda->addDecl(Field);
Modified: cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp Fri Jun 15 06:08:27 2012
@@ -740,7 +740,7 @@
FieldDecl *Field
= FieldDecl::Create(Context, Lambda, Loc, Loc, 0, ThisTy,
Context.getTrivialTypeSourceInfo(ThisTy, Loc),
- 0, false, false);
+ 0, false, ICIS_NoInit);
Field->setImplicit(true);
Field->setAccess(AS_private);
Lambda->addDecl(Field);
Modified: cfe/branches/tooling/lib/Sema/SemaExprMember.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExprMember.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExprMember.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExprMember.cpp Fri Jun 15 06:08:27 2012
@@ -1460,9 +1460,9 @@
/// \param HasTrailingLParen whether the next token is '(', which
/// is used to diagnose mis-uses of special members that can
/// only be called
-/// \param ObjCImpDecl the current ObjC @implementation decl;
-/// this is an ugly hack around the fact that ObjC @implementations
-/// aren't properly put in the context chain
+/// \param ObjCImpDecl the current Objective-C \@implementation
+/// decl; this is an ugly hack around the fact that Objective-C
+/// \@implementations aren't properly put in the context chain
ExprResult Sema::ActOnMemberAccessExpr(Scope *S, Expr *Base,
SourceLocation OpLoc,
tok::TokenKind OpKind,
Modified: cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp Fri Jun 15 06:08:27 2012
@@ -2820,14 +2820,23 @@
castedE = CCE->getSubExpr();
castedE = castedE->IgnoreImpCasts();
SourceRange range = castedE->getSourceRange();
+
+ SmallString<32> BridgeCall;
+
+ SourceManager &SM = S.getSourceManager();
+ char PrevChar = *SM.getCharacterData(range.getBegin().getLocWithOffset(-1));
+ if (Lexer::isIdentifierBodyChar(PrevChar, S.getLangOpts()))
+ BridgeCall += ' ';
+
+ BridgeCall += CFBridgeName;
+
if (isa<ParenExpr>(castedE)) {
DiagB.AddFixItHint(FixItHint::CreateInsertion(range.getBegin(),
- CFBridgeName));
+ BridgeCall));
} else {
- std::string namePlusParen = CFBridgeName;
- namePlusParen += "(";
+ BridgeCall += '(';
DiagB.AddFixItHint(FixItHint::CreateInsertion(range.getBegin(),
- namePlusParen));
+ BridgeCall));
DiagB.AddFixItHint(FixItHint::CreateInsertion(
S.PP.getLocForEndOfToken(range.getEnd()),
")"));
@@ -2909,7 +2918,8 @@
castType, castExpr, "__bridge ", 0);
}
{
- DiagnosticBuilder DiagB = S.Diag(noteLoc, diag::note_arc_bridge_transfer)
+ DiagnosticBuilder DiagB = S.Diag(br ? castExpr->getExprLoc() : noteLoc,
+ diag::note_arc_bridge_transfer)
<< castExprType << br;
addFixitForObjCARCConversion(S, DiagB, CCK, afterLParen,
castType, castExpr, "__bridge_transfer ",
@@ -2937,7 +2947,8 @@
castType, castExpr, "__bridge ", 0);
}
{
- DiagnosticBuilder DiagB = S.Diag(noteLoc, diag::note_arc_bridge_retained)
+ DiagnosticBuilder DiagB = S.Diag(br ? castExpr->getExprLoc() : noteLoc,
+ diag::note_arc_bridge_retained)
<< castType << br;
addFixitForObjCARCConversion(S, DiagB, CCK, afterLParen,
castType, castExpr, "__bridge_retained ",
Modified: cfe/branches/tooling/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaInit.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaInit.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaInit.cpp Fri Jun 15 06:08:27 2012
@@ -375,7 +375,7 @@
if (hadError)
return;
- FillInValueInitForField(Init, &*Field, Entity, ILE, RequiresSecondPass);
+ FillInValueInitForField(Init, *Field, Entity, ILE, RequiresSecondPass);
if (hadError)
return;
@@ -1336,9 +1336,9 @@
if (Field->getDeclName()) {
if (VerifyOnly)
CheckValueInitializable(
- InitializedEntity::InitializeMember(&*Field, &Entity));
+ InitializedEntity::InitializeMember(*Field, &Entity));
else
- StructuredList->setInitializedFieldInUnion(&*Field);
+ StructuredList->setInitializedFieldInUnion(*Field);
break;
}
}
@@ -1401,9 +1401,9 @@
// Make sure we can use this declaration.
bool InvalidUse;
if (VerifyOnly)
- InvalidUse = !SemaRef.CanUseDecl(&*Field);
+ InvalidUse = !SemaRef.CanUseDecl(*Field);
else
- InvalidUse = SemaRef.DiagnoseUseOfDecl(&*Field,
+ InvalidUse = SemaRef.DiagnoseUseOfDecl(*Field,
IList->getInit(Index)->getLocStart());
if (InvalidUse) {
++Index;
@@ -1413,14 +1413,14 @@
}
InitializedEntity MemberEntity =
- InitializedEntity::InitializeMember(&*Field, &Entity);
+ InitializedEntity::InitializeMember(*Field, &Entity);
CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
StructuredList, StructuredIndex);
InitializedSomething = true;
if (DeclType->isUnionType() && !VerifyOnly) {
// Initialize the first field within the union.
- StructuredList->setInitializedFieldInUnion(&*Field);
+ StructuredList->setInitializedFieldInUnion(*Field);
}
++Field;
@@ -1449,7 +1449,7 @@
for (; Field != FieldEnd && !hadError; ++Field) {
if (!Field->isUnnamedBitfield())
CheckValueInitializable(
- InitializedEntity::InitializeMember(&*Field, &Entity));
+ InitializedEntity::InitializeMember(*Field, &Entity));
}
}
@@ -1457,7 +1457,7 @@
Index >= IList->getNumInits())
return;
- if (CheckFlexibleArrayInit(Entity, IList->getInit(Index), &*Field,
+ if (CheckFlexibleArrayInit(Entity, IList->getInit(Index), *Field,
TopLevelObject)) {
hadError = true;
++Index;
@@ -1465,7 +1465,7 @@
}
InitializedEntity MemberEntity =
- InitializedEntity::InitializeMember(&*Field, &Entity);
+ InitializedEntity::InitializeMember(*Field, &Entity);
if (isa<InitListExpr>(IList->getInit(Index)))
CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
@@ -1679,7 +1679,7 @@
// IndirectFieldDecl that follow for the designated initializer.
if (!KnownField && Field->isAnonymousStructOrUnion()) {
if (IndirectFieldDecl *IF =
- FindIndirectFieldDesignator(&*Field, FieldName)) {
+ FindIndirectFieldDesignator(*Field, FieldName)) {
// In verify mode, don't modify the original.
if (VerifyOnly)
DIE = CloneDesignatedInitExpr(SemaRef, DIE);
@@ -1688,7 +1688,7 @@
break;
}
}
- if (KnownField && KnownField == &*Field)
+ if (KnownField && KnownField == *Field)
break;
if (FieldName && FieldName == Field->getIdentifier())
break;
@@ -1757,7 +1757,7 @@
if (Field->isUnnamedBitfield())
continue;
- if (ReplacementField == &*Field ||
+ if (ReplacementField == *Field ||
Field->getIdentifier() == ReplacementField->getIdentifier())
break;
@@ -1771,15 +1771,15 @@
if (RT->getDecl()->isUnion()) {
FieldIndex = 0;
if (!VerifyOnly)
- StructuredList->setInitializedFieldInUnion(&*Field);
+ StructuredList->setInitializedFieldInUnion(*Field);
}
// Make sure we can use this declaration.
bool InvalidUse;
if (VerifyOnly)
- InvalidUse = !SemaRef.CanUseDecl(&*Field);
+ InvalidUse = !SemaRef.CanUseDecl(*Field);
else
- InvalidUse = SemaRef.DiagnoseUseOfDecl(&*Field, D->getFieldLoc());
+ InvalidUse = SemaRef.DiagnoseUseOfDecl(*Field, D->getFieldLoc());
if (InvalidUse) {
++Index;
return true;
@@ -1787,7 +1787,7 @@
if (!VerifyOnly) {
// Update the designator with the field declaration.
- D->setField(&*Field);
+ D->setField(*Field);
// Make sure that our non-designated initializer list has space
// for a subobject corresponding to this field.
@@ -1809,7 +1809,7 @@
<< SourceRange(NextD->getStartLocation(),
DIE->getSourceRange().getEnd());
SemaRef.Diag(Field->getLocation(), diag::note_flexible_array_member)
- << &*Field;
+ << *Field;
}
Invalid = true;
}
@@ -1822,13 +1822,13 @@
diag::err_flexible_array_init_needs_braces)
<< DIE->getInit()->getSourceRange();
SemaRef.Diag(Field->getLocation(), diag::note_flexible_array_member)
- << &*Field;
+ << *Field;
}
Invalid = true;
}
// Check GNU flexible array initializer.
- if (!Invalid && CheckFlexibleArrayInit(Entity, DIE->getInit(), &*Field,
+ if (!Invalid && CheckFlexibleArrayInit(Entity, DIE->getInit(), *Field,
TopLevelObject))
Invalid = true;
@@ -1844,7 +1844,7 @@
IList->setInit(Index, DIE->getInit());
InitializedEntity MemberEntity =
- InitializedEntity::InitializeMember(&*Field, &Entity);
+ InitializedEntity::InitializeMember(*Field, &Entity);
CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
StructuredList, newStructuredIndex);
@@ -1863,7 +1863,7 @@
unsigned newStructuredIndex = FieldIndex;
InitializedEntity MemberEntity =
- InitializedEntity::InitializeMember(&*Field, &Entity);
+ InitializedEntity::InitializeMember(*Field, &Entity);
if (CheckDesignatedInitializer(MemberEntity, IList, DIE, DesigIdx + 1,
FieldType, 0, 0, Index,
StructuredList, newStructuredIndex,
@@ -4408,7 +4408,7 @@
/// \param T The type of the temporary object, which must either be
/// the type of the initializer expression or a superclass thereof.
///
-/// \param Enter The entity being initialized.
+/// \param Entity The entity being initialized.
///
/// \param CurInit The initializer expression.
///
Modified: cfe/branches/tooling/lib/Sema/SemaLambda.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaLambda.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaLambda.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaLambda.cpp Fri Jun 15 06:08:27 2012
@@ -444,7 +444,7 @@
SmallVector<Decl*, 4> Fields;
for (RecordDecl::field_iterator i = Class->field_begin(),
e = Class->field_end(); i != e; ++i)
- Fields.push_back(&*i);
+ Fields.push_back(*i);
ActOnFields(0, Class->getLocation(), Class, Fields,
SourceLocation(), SourceLocation(), 0);
CheckCompletedCXXClass(Class);
@@ -690,7 +690,7 @@
SmallVector<Decl*, 4> Fields;
for (RecordDecl::field_iterator i = Class->field_begin(),
e = Class->field_end(); i != e; ++i)
- Fields.push_back(&*i);
+ Fields.push_back(*i);
ActOnFields(0, Class->getLocation(), Class, Fields,
SourceLocation(), SourceLocation(), 0);
CheckCompletedCXXClass(Class);
Modified: cfe/branches/tooling/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaLookup.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaLookup.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaLookup.cpp Fri Jun 15 06:08:27 2012
@@ -1069,7 +1069,7 @@
for (Decl::redecl_iterator RD = D->redecls_begin(), RDEnd = D->redecls_end();
RD != RDEnd; ++RD) {
- if (NamedDecl *ND = dyn_cast<NamedDecl>(RD)) {
+ if (NamedDecl *ND = dyn_cast<NamedDecl>(*RD)) {
if (LookupResult::isVisible(ND))
return ND;
}
@@ -3533,7 +3533,16 @@
/// \brief Add keywords to the consumer as possible typo corrections.
static void AddKeywordsToConsumer(Sema &SemaRef,
TypoCorrectionConsumer &Consumer,
- Scope *S, CorrectionCandidateCallback &CCC) {
+ Scope *S, CorrectionCandidateCallback &CCC,
+ bool AfterNestedNameSpecifier) {
+ if (AfterNestedNameSpecifier) {
+ // For 'X::', we know exactly which keywords can appear next.
+ Consumer.addKeywordResult("template");
+ if (CCC.WantExpressionKeywords)
+ Consumer.addKeywordResult("operator");
+ return;
+ }
+
if (CCC.WantObjCSuper)
Consumer.addKeywordResult("super");
@@ -3795,6 +3804,9 @@
bool SearchNamespaces
= getLangOpts().CPlusPlus &&
(IsUnqualifiedLookup || (QualifiedDC && QualifiedDC->isNamespace()));
+ // In a few cases we *only* want to search for corrections bases on just
+ // adding or changing the nested name specifier.
+ bool AllowOnlyNNSChanges = Typo->getName().size() < 3;
if (IsUnqualifiedLookup || SearchNamespaces) {
// For unqualified lookup, look through all of the names that we have
@@ -3820,7 +3832,7 @@
}
}
- AddKeywordsToConsumer(*this, Consumer, S, CCC);
+ AddKeywordsToConsumer(*this, Consumer, S, CCC, SS && SS->isNotEmpty());
// If we haven't found anything, we're done.
if (Consumer.empty()) {
@@ -3831,8 +3843,8 @@
return TypoCorrection();
}
- // Make sure that the user typed at least 3 characters for each correction
- // made. Otherwise, we don't even both looking at the results.
+ // Make sure the best edit distance (prior to adding any namespace qualifiers)
+ // is not more that about a third of the length of the typo's identifier.
unsigned ED = Consumer.getBestEditDistance(true);
if (ED > 0 && Typo->getName().size() / ED < 3) {
// If this was an unqualified lookup, note that no correction was found.
@@ -3872,6 +3884,16 @@
for (TypoCorrectionConsumer::result_iterator I = DI->second.begin(),
IEnd = DI->second.end();
I != IEnd; /* Increment in loop. */) {
+ // If we only want nested name specifier corrections, ignore potential
+ // corrections that have a different base identifier from the typo.
+ if (AllowOnlyNNSChanges &&
+ I->second.front().getCorrectionAsIdentifierInfo() != Typo) {
+ TypoCorrectionConsumer::result_iterator Prev = I;
+ ++I;
+ DI->second.erase(Prev);
+ continue;
+ }
+
// If the item already has been looked up or is a keyword, keep it.
// If a validator callback object was given, drop the correction
// unless it passes validation.
@@ -4013,7 +4035,7 @@
TypoResultsMap &BestResults = Consumer.getBestResults();
ED = Consumer.getBestEditDistance(true);
- if (ED > 0 && Typo->getName().size() / ED < 3) {
+ if (!AllowOnlyNNSChanges && ED > 0 && Typo->getName().size() / ED < 3) {
// If this was an unqualified lookup and we believe the callback
// object wouldn't have filtered out possible corrections, note
// that no correction was found.
Modified: cfe/branches/tooling/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaObjCProperty.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaObjCProperty.cpp Fri Jun 15 06:08:27 2012
@@ -603,7 +603,7 @@
/// ActOnPropertyImplDecl - This routine performs semantic checks and
/// builds the AST node for a property implementation declaration; declared
-/// as @synthesize or @dynamic.
+/// as \@synthesize or \@dynamic.
///
Decl *Sema::ActOnPropertyImplDecl(Scope *S,
SourceLocation AtLoc,
@@ -1154,11 +1154,11 @@
// FIXME: O(N^2)
for (ObjCInterfaceDecl::prop_iterator S = SDecl->prop_begin(),
E = SDecl->prop_end(); S != E; ++S) {
- ObjCPropertyDecl *SuperPDecl = &*S;
+ ObjCPropertyDecl *SuperPDecl = *S;
// Does property in super class has declaration in current class?
for (ObjCInterfaceDecl::prop_iterator I = IDecl->prop_begin(),
E = IDecl->prop_end(); I != E; ++I) {
- ObjCPropertyDecl *PDecl = &*I;
+ ObjCPropertyDecl *PDecl = *I;
if (SuperPDecl->getIdentifier() == PDecl->getIdentifier())
DiagnosePropertyMismatch(PDecl, SuperPDecl,
SDecl->getIdentifier());
@@ -1180,7 +1180,7 @@
if (!CatDecl->IsClassExtension())
for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(),
E = PDecl->prop_end(); P != E; ++P) {
- ObjCPropertyDecl *Pr = &*P;
+ ObjCPropertyDecl *Pr = *P;
ObjCCategoryDecl::prop_iterator CP, CE;
// Is this property already in category's list of properties?
for (CP = CatDecl->prop_begin(), CE = CatDecl->prop_end(); CP!=CE; ++CP)
@@ -1188,13 +1188,13 @@
break;
if (CP != CE)
// Property protocol already exist in class. Diagnose any mismatch.
- DiagnosePropertyMismatch(&*CP, Pr, PDecl->getIdentifier());
+ DiagnosePropertyMismatch(*CP, Pr, PDecl->getIdentifier());
}
return;
}
for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(),
E = PDecl->prop_end(); P != E; ++P) {
- ObjCPropertyDecl *Pr = &*P;
+ ObjCPropertyDecl *Pr = *P;
ObjCInterfaceDecl::prop_iterator CP, CE;
// Is this property already in class's list of properties?
for (CP = IDecl->prop_begin(), CE = IDecl->prop_end(); CP != CE; ++CP)
@@ -1202,7 +1202,7 @@
break;
if (CP != CE)
// Property protocol already exist in class. Diagnose any mismatch.
- DiagnosePropertyMismatch(&*CP, Pr, PDecl->getIdentifier());
+ DiagnosePropertyMismatch(*CP, Pr, PDecl->getIdentifier());
}
}
@@ -1318,7 +1318,7 @@
if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(CDecl)) {
for (ObjCContainerDecl::prop_iterator P = IDecl->prop_begin(),
E = IDecl->prop_end(); P != E; ++P) {
- ObjCPropertyDecl *Prop = &*P;
+ ObjCPropertyDecl *Prop = *P;
PropMap[Prop->getIdentifier()] = Prop;
}
// scan through class's protocols.
@@ -1331,7 +1331,7 @@
if (!CATDecl->IsClassExtension())
for (ObjCContainerDecl::prop_iterator P = CATDecl->prop_begin(),
E = CATDecl->prop_end(); P != E; ++P) {
- ObjCPropertyDecl *Prop = &*P;
+ ObjCPropertyDecl *Prop = *P;
PropMap[Prop->getIdentifier()] = Prop;
}
// scan through class's protocols.
@@ -1342,7 +1342,7 @@
else if (ObjCProtocolDecl *PDecl = dyn_cast<ObjCProtocolDecl>(CDecl)) {
for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(),
E = PDecl->prop_end(); P != E; ++P) {
- ObjCPropertyDecl *Prop = &*P;
+ ObjCPropertyDecl *Prop = *P;
ObjCPropertyDecl *PropertyFromSuper = SuperPropMap[Prop->getIdentifier()];
// Exclude property for protocols which conform to class's super-class,
// as super-class has to implement the property.
@@ -1368,7 +1368,7 @@
if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(CDecl)) {
for (ObjCContainerDecl::prop_iterator P = IDecl->prop_begin(),
E = IDecl->prop_end(); P != E; ++P) {
- ObjCPropertyDecl *Prop = &*P;
+ ObjCPropertyDecl *Prop = *P;
PropMap[Prop->getIdentifier()] = Prop;
}
for (ObjCInterfaceDecl::all_protocol_iterator
@@ -1379,7 +1379,7 @@
else if (ObjCProtocolDecl *PDecl = dyn_cast<ObjCProtocolDecl>(CDecl)) {
for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(),
E = PDecl->prop_end(); P != E; ++P) {
- ObjCPropertyDecl *Prop = &*P;
+ ObjCPropertyDecl *Prop = *P;
if (!PropMap.count(Prop->getIdentifier()))
PropMap[Prop->getIdentifier()] = Prop;
}
@@ -1411,7 +1411,7 @@
dyn_cast<ObjCInterfaceDecl>(CDecl)) {
for (ObjCContainerDecl::prop_iterator P = IDecl->prop_begin(),
E = IDecl->prop_end(); P != E; ++P) {
- ObjCPropertyDecl *Prop = &*P;
+ ObjCPropertyDecl *Prop = *P;
if (Prop->getIdentifier() == II)
return Prop;
}
@@ -1428,7 +1428,7 @@
dyn_cast<ObjCProtocolDecl>(CDecl)) {
for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(),
E = PDecl->prop_end(); P != E; ++P) {
- ObjCPropertyDecl *Prop = &*P;
+ ObjCPropertyDecl *Prop = *P;
if (Prop->getIdentifier() == II)
return Prop;
}
@@ -1453,8 +1453,8 @@
return &Ctx.Idents.get(ivarName.str());
}
-/// DefaultSynthesizeProperties - This routine default synthesizes all
-/// properties which must be synthesized in class's @implementation.
+/// \brief Default synthesizes all properties which must be synthesized
+/// in class's \@implementation.
void Sema::DefaultSynthesizeProperties(Scope *S, ObjCImplDecl* IMPDecl,
ObjCInterfaceDecl *IDecl) {
@@ -1502,7 +1502,7 @@
true,
/* property = */ Prop->getIdentifier(),
/* ivar = */ getDefaultSynthIvarName(Prop, Context),
- SourceLocation()));
+ Prop->getLocation()));
if (PIDecl) {
Diag(Prop->getLocation(), diag::warn_missing_explicit_synthesis);
Diag(IMPDecl->getLocation(), diag::note_while_in_implementation);
@@ -1587,7 +1587,7 @@
for (ObjCContainerDecl::prop_iterator I = IDecl->prop_begin(),
E = IDecl->prop_end();
I != E; ++I) {
- ObjCPropertyDecl *Property = &*I;
+ ObjCPropertyDecl *Property = *I;
ObjCMethodDecl *GetterMethod = 0;
ObjCMethodDecl *SetterMethod = 0;
bool LookedUpGetterSetter = false;
@@ -1674,7 +1674,7 @@
for (ObjCImplementationDecl::propimpl_iterator
i = D->propimpl_begin(), e = D->propimpl_end(); i != e; ++i) {
- ObjCPropertyImplDecl *PID = &*i;
+ ObjCPropertyImplDecl *PID = *i;
if (PID->getPropertyImplementation() != ObjCPropertyImplDecl::Synthesize)
continue;
Modified: cfe/branches/tooling/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaOverload.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaOverload.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaOverload.cpp Fri Jun 15 06:08:27 2012
@@ -389,11 +389,20 @@
const unsigned ToWidth = Ctx.getIntWidth(ToType);
if (FromWidth > ToWidth ||
- (FromWidth == ToWidth && FromSigned != ToSigned)) {
+ (FromWidth == ToWidth && FromSigned != ToSigned) ||
+ (FromSigned && !ToSigned)) {
// Not all values of FromType can be represented in ToType.
llvm::APSInt InitializerValue;
const Expr *Initializer = IgnoreNarrowingConversion(Converted);
- if (Initializer->isIntegerConstantExpr(InitializerValue, Ctx)) {
+ if (!Initializer->isIntegerConstantExpr(InitializerValue, Ctx)) {
+ // Such conversions on variables are always narrowing.
+ return NK_Variable_Narrowing;
+ } else if (FromWidth < ToWidth) {
+ // Negative -> unsigned is narrowing. Otherwise, more bits is never
+ // narrowing.
+ if (InitializerValue.isSigned() && InitializerValue.isNegative())
+ return NK_Constant_Narrowing;
+ } else {
ConstantValue = APValue(InitializerValue);
// Add a bit to the InitializerValue so we don't have to worry about
@@ -411,9 +420,6 @@
ConstantType = Initializer->getType();
return NK_Constant_Narrowing;
}
- } else {
- // Variables are always narrowings.
- return NK_Variable_Narrowing;
}
}
return NK_Not_Narrowing;
@@ -5212,7 +5218,7 @@
/// @p SuppressUserConversions, then don't allow user-defined
/// conversions via constructors or conversion operators.
///
-/// \para PartialOverloading true if we are performing "partial" overloading
+/// \param PartialOverloading true if we are performing "partial" overloading
/// based on an incomplete set of function arguments. This feature is used by
/// code completion.
void
@@ -6399,12 +6405,12 @@
// The "promoted arithmetic types" are the arithmetic
// types are that preserved by promotion (C++ [over.built]p2).
static const unsigned FirstIntegralType = 3;
- static const unsigned LastIntegralType = 18;
+ static const unsigned LastIntegralType = 20;
static const unsigned FirstPromotedIntegralType = 3,
- LastPromotedIntegralType = 9;
+ LastPromotedIntegralType = 11;
static const unsigned FirstPromotedArithmeticType = 0,
- LastPromotedArithmeticType = 9;
- static const unsigned NumArithmeticTypes = 18;
+ LastPromotedArithmeticType = 11;
+ static const unsigned NumArithmeticTypes = 20;
/// \brief Get the canonical type for a given arithmetic type index.
CanQualType getArithmeticType(unsigned index) {
@@ -6420,9 +6426,11 @@
&ASTContext::IntTy,
&ASTContext::LongTy,
&ASTContext::LongLongTy,
+ &ASTContext::Int128Ty,
&ASTContext::UnsignedIntTy,
&ASTContext::UnsignedLongTy,
&ASTContext::UnsignedLongLongTy,
+ &ASTContext::UnsignedInt128Ty,
// End of promoted types.
&ASTContext::BoolTy,
@@ -6435,7 +6443,7 @@
&ASTContext::UnsignedCharTy,
&ASTContext::UnsignedShortTy,
// End of integral types.
- // FIXME: What about complex?
+ // FIXME: What about complex? What about half?
};
return S.Context.*ArithmeticTypes[index];
}
@@ -6454,20 +6462,24 @@
// *except* when dealing with signed types of higher rank.
// (we could precompute SLL x UI for all known platforms, but it's
// better not to make any assumptions).
+ // We assume that int128 has a higher rank than long long on all platforms.
enum PromotedType {
- Flt, Dbl, LDbl, SI, SL, SLL, UI, UL, ULL, Dep=-1
+ Dep=-1,
+ Flt, Dbl, LDbl, SI, SL, SLL, S128, UI, UL, ULL, U128
};
static const PromotedType ConversionsTable[LastPromotedArithmeticType]
[LastPromotedArithmeticType] = {
- /* Flt*/ { Flt, Dbl, LDbl, Flt, Flt, Flt, Flt, Flt, Flt },
- /* Dbl*/ { Dbl, Dbl, LDbl, Dbl, Dbl, Dbl, Dbl, Dbl, Dbl },
- /*LDbl*/ { LDbl, LDbl, LDbl, LDbl, LDbl, LDbl, LDbl, LDbl, LDbl },
- /* SI*/ { Flt, Dbl, LDbl, SI, SL, SLL, UI, UL, ULL },
- /* SL*/ { Flt, Dbl, LDbl, SL, SL, SLL, Dep, UL, ULL },
- /* SLL*/ { Flt, Dbl, LDbl, SLL, SLL, SLL, Dep, Dep, ULL },
- /* UI*/ { Flt, Dbl, LDbl, UI, Dep, Dep, UI, UL, ULL },
- /* UL*/ { Flt, Dbl, LDbl, UL, UL, Dep, UL, UL, ULL },
- /* ULL*/ { Flt, Dbl, LDbl, ULL, ULL, ULL, ULL, ULL, ULL },
+/* Flt*/ { Flt, Dbl, LDbl, Flt, Flt, Flt, Flt, Flt, Flt, Flt, Flt },
+/* Dbl*/ { Dbl, Dbl, LDbl, Dbl, Dbl, Dbl, Dbl, Dbl, Dbl, Dbl, Dbl },
+/*LDbl*/ { LDbl, LDbl, LDbl, LDbl, LDbl, LDbl, LDbl, LDbl, LDbl, LDbl, LDbl },
+/* SI*/ { Flt, Dbl, LDbl, SI, SL, SLL, S128, UI, UL, ULL, U128 },
+/* SL*/ { Flt, Dbl, LDbl, SL, SL, SLL, S128, Dep, UL, ULL, U128 },
+/* SLL*/ { Flt, Dbl, LDbl, SLL, SLL, SLL, S128, Dep, Dep, ULL, U128 },
+/*S128*/ { Flt, Dbl, LDbl, S128, S128, S128, S128, S128, S128, S128, U128 },
+/* UI*/ { Flt, Dbl, LDbl, UI, Dep, Dep, S128, UI, UL, ULL, U128 },
+/* UL*/ { Flt, Dbl, LDbl, UL, UL, Dep, S128, UL, UL, ULL, U128 },
+/* ULL*/ { Flt, Dbl, LDbl, ULL, ULL, ULL, S128, ULL, ULL, ULL, U128 },
+/*U128*/ { Flt, Dbl, LDbl, U128, U128, U128, U128, U128, U128, U128, U128 },
};
assert(L < LastPromotedArithmeticType);
@@ -6567,13 +6579,13 @@
assert(getArithmeticType(FirstPromotedIntegralType) == S.Context.IntTy &&
"Invalid first promoted integral type");
assert(getArithmeticType(LastPromotedIntegralType - 1)
- == S.Context.UnsignedLongLongTy &&
+ == S.Context.UnsignedInt128Ty &&
"Invalid last promoted integral type");
assert(getArithmeticType(FirstPromotedArithmeticType)
== S.Context.FloatTy &&
"Invalid first promoted arithmetic type");
assert(getArithmeticType(LastPromotedArithmeticType - 1)
- == S.Context.UnsignedLongLongTy &&
+ == S.Context.UnsignedInt128Ty &&
"Invalid last promoted arithmetic type");
}
Modified: cfe/branches/tooling/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaStmt.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaStmt.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaStmt.cpp Fri Jun 15 06:08:27 2012
@@ -947,7 +947,7 @@
EDI != ED->enumerator_end(); ++EDI) {
llvm::APSInt Val = EDI->getInitVal();
AdjustAPSInt(Val, CondWidth, CondIsSigned);
- EnumVals.push_back(std::make_pair(Val, &*EDI));
+ EnumVals.push_back(std::make_pair(Val, *EDI));
}
std::stable_sort(EnumVals.begin(), EnumVals.end(), CmpEnumVals);
EnumValsTy::iterator EIend =
@@ -1116,18 +1116,15 @@
llvm::SmallPtrSet<VarDecl*, 8> &Decls;
llvm::SmallVector<SourceRange, 10> &Ranges;
bool Simple;
- PartialDiagnostic &PDiag;
public:
typedef EvaluatedExprVisitor<DeclExtractor> Inherited;
DeclExtractor(Sema &S, llvm::SmallPtrSet<VarDecl*, 8> &Decls,
- llvm::SmallVector<SourceRange, 10> &Ranges,
- PartialDiagnostic &PDiag) :
+ llvm::SmallVector<SourceRange, 10> &Ranges) :
Inherited(S.Context),
Decls(Decls),
Ranges(Ranges),
- Simple(true),
- PDiag(PDiag) {}
+ Simple(true) {}
bool isSimple() { return Simple; }
@@ -1196,7 +1193,6 @@
class DeclMatcher : public EvaluatedExprVisitor<DeclMatcher> {
llvm::SmallPtrSet<VarDecl*, 8> &Decls;
bool FoundDecl;
- //bool EvalDecl;
public:
typedef EvaluatedExprVisitor<DeclMatcher> Inherited;
@@ -1274,7 +1270,7 @@
PartialDiagnostic PDiag = S.PDiag(diag::warn_variables_not_in_loop_body);
llvm::SmallPtrSet<VarDecl*, 8> Decls;
llvm::SmallVector<SourceRange, 10> Ranges;
- DeclExtractor DE(S, Decls, Ranges, PDiag);
+ DeclExtractor DE(S, Decls, Ranges);
DE.Visit(Second);
// Don't analyze complex conditionals.
@@ -2674,6 +2670,15 @@
return Owned(NS);
}
+StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc,
+ std::string &AsmString,
+ SourceLocation EndLoc) {
+ MSAsmStmt *NS =
+ new (Context) MSAsmStmt(Context, AsmLoc, AsmString, EndLoc);
+
+ return Owned(NS);
+}
+
StmtResult
Sema::ActOnObjCAtCatchStmt(SourceLocation AtLoc,
SourceLocation RParen, Decl *Parm,
Modified: cfe/branches/tooling/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaTemplate.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaTemplate.cpp Fri Jun 15 06:08:27 2012
@@ -745,7 +745,7 @@
}
/// ActOnTemplateTemplateParameter - Called when a C++ template template
-/// parameter (e.g. T in template <template <typename> class T> class array)
+/// parameter (e.g. T in template <template \<typename> class T> class array)
/// has been parsed. S is the current scope.
Decl *Sema::ActOnTemplateTemplateParameter(Scope* S,
SourceLocation TmpLoc,
@@ -2453,22 +2453,20 @@
NameInfo = ArgExpr->getNameInfo();
} else if (CXXDependentScopeMemberExpr *ArgExpr =
dyn_cast<CXXDependentScopeMemberExpr>(Arg.getAsExpr())) {
- SS.Adopt(ArgExpr->getQualifierLoc());
- NameInfo = ArgExpr->getMemberNameInfo();
+ if (ArgExpr->isImplicitAccess()) {
+ SS.Adopt(ArgExpr->getQualifierLoc());
+ NameInfo = ArgExpr->getMemberNameInfo();
+ }
}
- if (NameInfo.getName()) {
+ if (NameInfo.getName().isIdentifier()) {
LookupResult Result(*this, NameInfo, LookupOrdinaryName);
LookupParsedName(Result, CurScope, &SS);
- bool CouldBeType = Result.getResultKind() ==
- LookupResult::NotFoundInCurrentInstantiation;
-
- for (LookupResult::iterator I = Result.begin(), IEnd = Result.end();
- !CouldBeType && I != IEnd; ++I) {
- CouldBeType = isa<TypeDecl>(*I);
- }
- if (CouldBeType) {
+ if (Result.getAsSingle<TypeDecl>() ||
+ Result.getResultKind() ==
+ LookupResult::NotFoundInCurrentInstantiation) {
+ // FIXME: Add a FixIt and fix up the template argument for recovery.
SourceLocation Loc = AL.getSourceRange().getBegin();
Diag(Loc, diag::err_template_arg_must_be_type_suggest);
Diag(Param->getLocation(), diag::note_template_param_here);
@@ -4125,7 +4123,8 @@
IntegerType = Enum->getDecl()->getIntegerType();
Value = Value.extOrTrunc(Context.getTypeSize(IntegerType));
- Converted = TemplateArgument(Value, Context.getCanonicalType(ParamType));
+ Converted = TemplateArgument(Context, Value,
+ Context.getCanonicalType(ParamType));
return ArgResult;
}
@@ -4251,7 +4250,7 @@
}
}
- Converted = TemplateArgument(Value,
+ Converted = TemplateArgument(Context, Value,
ParamType->isEnumeralType()
? Context.getCanonicalType(ParamType)
: IntegerType);
@@ -4569,13 +4568,13 @@
Kind = CharacterLiteral::Ascii;
return Owned(new (Context) CharacterLiteral(
- Arg.getAsIntegral()->getZExtValue(),
+ Arg.getAsIntegral().getZExtValue(),
Kind, T, Loc));
}
if (T->isBooleanType())
return Owned(new (Context) CXXBoolLiteralExpr(
- Arg.getAsIntegral()->getBoolValue(),
+ Arg.getAsIntegral().getBoolValue(),
T, Loc));
if (T->isNullPtrType())
@@ -4590,7 +4589,7 @@
else
BT = T;
- Expr *E = IntegerLiteral::Create(Context, *Arg.getAsIntegral(), BT, Loc);
+ Expr *E = IntegerLiteral::Create(Context, Arg.getAsIntegral(), BT, Loc);
if (T->isEnumeralType()) {
// FIXME: This is a hack. We need a better way to handle substituted
// non-type template parameters.
@@ -5113,7 +5112,7 @@
/// \param TemplateParams the template parameters of the primary class
/// template.
///
-/// \param TemplateArg the template arguments of the class template
+/// \param TemplateArgs the template arguments of the class template
/// partial specialization.
///
/// \returns true if there was an error, false otherwise.
Modified: cfe/branches/tooling/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaTemplateDeduction.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaTemplateDeduction.cpp Fri Jun 15 06:08:27 2012
@@ -193,7 +193,7 @@
if (Y.getKind() == TemplateArgument::Expression ||
Y.getKind() == TemplateArgument::Declaration ||
(Y.getKind() == TemplateArgument::Integral &&
- hasSameExtendedValue(*X.getAsIntegral(), *Y.getAsIntegral())))
+ hasSameExtendedValue(X.getAsIntegral(), Y.getAsIntegral())))
return DeducedTemplateArgument(X,
X.wasDeducedFromArrayBound() &&
Y.wasDeducedFromArrayBound());
@@ -293,7 +293,8 @@
assert(NTTP->getDepth() == 0 &&
"Cannot deduce non-type template argument with depth > 0");
- DeducedTemplateArgument NewDeduced(Value, ValueType, DeducedFromArrayBound);
+ DeducedTemplateArgument NewDeduced(S.Context, Value, ValueType,
+ DeducedFromArrayBound);
DeducedTemplateArgument Result = checkDeducedTemplateArguments(S.Context,
Deduced[NTTP->getIndex()],
NewDeduced);
@@ -1595,7 +1596,7 @@
case TemplateArgument::Integral:
if (Arg.getKind() == TemplateArgument::Integral) {
- if (hasSameExtendedValue(*Param.getAsIntegral(), *Arg.getAsIntegral()))
+ if (hasSameExtendedValue(Param.getAsIntegral(), Arg.getAsIntegral()))
return Sema::TDK_Success;
Info.FirstArg = Param;
@@ -1618,7 +1619,7 @@
= getDeducedParameterFromExpr(Param.getAsExpr())) {
if (Arg.getKind() == TemplateArgument::Integral)
return DeduceNonTypeTemplateArgument(S, NTTP,
- *Arg.getAsIntegral(),
+ Arg.getAsIntegral(),
Arg.getIntegralType(),
/*ArrayBound=*/false,
Info, Deduced);
@@ -1867,7 +1868,7 @@
Y.getAsTemplateOrTemplatePattern()).getAsVoidPointer();
case TemplateArgument::Integral:
- return *X.getAsIntegral() == *Y.getAsIntegral();
+ return X.getAsIntegral() == Y.getAsIntegral();
case TemplateArgument::Expression: {
llvm::FoldingSetNodeID XID, YID;
@@ -1898,7 +1899,7 @@
///
/// \param S The semantic analysis object.
///
-/// \param The template argument we are producing template argument
+/// \param Arg The template argument we are producing template argument
/// location information for.
///
/// \param NTTPType For a declaration template argument, the type of
@@ -2198,7 +2199,7 @@
/// \param FunctionTemplate the function template into which the explicit
/// template arguments will be substituted.
///
-/// \param ExplicitTemplateArguments the explicitly-specified template
+/// \param ExplicitTemplateArgs the explicitly-specified template
/// arguments.
///
/// \param Deduced the deduced template arguments, which will be populated
Modified: cfe/branches/tooling/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaTemplateInstantiate.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaTemplateInstantiate.cpp Fri Jun 15 06:08:27 2012
@@ -1383,7 +1383,7 @@
/// substituted. If this type is not dependent, it will be returned
/// immediately.
///
-/// \param TemplateArgs the template arguments that will be
+/// \param Args the template arguments that will be
/// substituted for the top-level template parameters within T.
///
/// \param Loc the location in the source code where this substitution
@@ -1963,9 +1963,7 @@
Expr *Init = NewInit.take();
assert(Init && "no-argument initializer in class");
assert(!isa<ParenListExpr>(Init) && "call-style init in class");
- ActOnCXXInClassMemberInitializer(NewField,
- Init->getSourceRange().getBegin(),
- Init);
+ ActOnCXXInClassMemberInitializer(NewField, Init->getLocStart(), Init);
}
}
}
Modified: cfe/branches/tooling/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaTemplateInstantiateDecl.cpp Fri Jun 15 06:08:27 2012
@@ -430,7 +430,7 @@
D->getLocation(),
D->isMutable(),
BitWidth,
- D->hasInClassInitializer(),
+ D->getInClassInitStyle(),
D->getInnerLocStart(),
D->getAccess(),
0);
@@ -672,7 +672,7 @@
}
if (EnumConst) {
- SemaRef.InstantiateAttrs(TemplateArgs, &*EC, EnumConst);
+ SemaRef.InstantiateAttrs(TemplateArgs, *EC, EnumConst);
EnumConst->setAccess(Enum->getAccess());
Enum->addDecl(EnumConst);
@@ -683,7 +683,7 @@
!Enum->isScoped()) {
// If the enumeration is within a function or method, record the enum
// constant as a local.
- SemaRef.CurrentInstantiationScope->InstantiatedLocal(&*EC, EnumConst);
+ SemaRef.CurrentInstantiationScope->InstantiatedLocal(*EC, EnumConst);
}
}
}
@@ -3240,8 +3240,8 @@
///
/// In the instantiation of X<int>::getKind(), we need to map the
/// EnumConstantDecl for KnownValue (which refers to
-/// X<T>::<Kind>::KnownValue) to its instantiation
-/// (X<int>::<Kind>::KnownValue). InstantiateCurrentDeclRef() performs
+/// X<T>::\<Kind>::KnownValue) to its instantiation
+/// (X<int>::\<Kind>::KnownValue). InstantiateCurrentDeclRef() performs
/// this mapping from within the instantiation of X<int>.
NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
const MultiLevelTemplateArgumentList &TemplateArgs) {
Modified: cfe/branches/tooling/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaType.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaType.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaType.cpp Fri Jun 15 06:08:27 2012
@@ -573,7 +573,8 @@
/// \brief Convert the specified declspec to the appropriate type
/// object.
-/// \param D the declarator containing the declaration specifier.
+/// \param state Specifies the declarator containing the declaration specifier
+/// to be converted, along with other associated processing state.
/// \returns The type described by the declaration specifiers. This function
/// never returns null.
static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
@@ -1594,10 +1595,6 @@
///
/// \param CVR The cvr-qualifiers to be applied to the block pointer type.
///
-/// \param Loc The location of the entity whose type involves this
-/// block pointer type or, if there is no such entity, the location of the
-/// type that will have block pointer type.
-///
/// \param Entity The name of the entity that involves the block pointer
/// type, if known.
///
@@ -1901,7 +1898,7 @@
DeclaratorChunk &DeclType = D.getTypeObject(chunkIndex);
if (DeclType.Kind == DeclaratorChunk::Function) {
const DeclaratorChunk::FunctionTypeInfo &FTI = DeclType.Fun;
- if (FTI.TrailingReturnType) {
+ if (FTI.hasTrailingReturnType()) {
Error = -1;
break;
}
@@ -2176,12 +2173,12 @@
// trailing-return-type is only required if we're declaring a function,
// and not, for instance, a pointer to a function.
if (D.getDeclSpec().getTypeSpecType() == DeclSpec::TST_auto &&
- !FTI.TrailingReturnType && chunkIndex == 0) {
+ !FTI.hasTrailingReturnType() && chunkIndex == 0) {
S.Diag(D.getDeclSpec().getTypeSpecTypeLoc(),
diag::err_auto_missing_trailing_return);
T = Context.IntTy;
D.setInvalidType(true);
- } else if (FTI.TrailingReturnType) {
+ } else if (FTI.hasTrailingReturnType()) {
// T must be exactly 'auto' at this point. See CWG issue 681.
if (isa<ParenType>(T)) {
S.Diag(D.getDeclSpec().getTypeSpecTypeLoc(),
@@ -2195,10 +2192,12 @@
<< T << D.getDeclSpec().getSourceRange();
D.setInvalidType(true);
}
-
- T = S.GetTypeFromParser(
- ParsedType::getFromOpaquePtr(FTI.TrailingReturnType),
- &TInfo);
+ T = S.GetTypeFromParser(FTI.getTrailingReturnType(), &TInfo);
+ if (T.isNull()) {
+ // An error occurred parsing the trailing return type.
+ T = Context.IntTy;
+ D.setInvalidType(true);
+ }
}
}
@@ -2301,7 +2300,7 @@
FunctionProtoType::ExtProtoInfo EPI;
EPI.Variadic = FTI.isVariadic;
- EPI.HasTrailingReturn = FTI.TrailingReturnType;
+ EPI.HasTrailingReturn = FTI.hasTrailingReturnType();
EPI.TypeQuals = FTI.TypeQuals;
EPI.RefQualifier = !FTI.hasRefQualifier()? RQ_None
: FTI.RefQualifierIsLValueRef? RQ_LValue
@@ -3119,7 +3118,7 @@
assert(Chunk.Kind == DeclaratorChunk::Function);
TL.setLocalRangeBegin(Chunk.Loc);
TL.setLocalRangeEnd(Chunk.EndLoc);
- TL.setTrailingReturn(!!Chunk.Fun.TrailingReturnType);
+ TL.setTrailingReturn(Chunk.Fun.hasTrailingReturnType());
const DeclaratorChunk::FunctionTypeInfo &FTI = Chunk.Fun;
for (unsigned i = 0, e = TL.getNumArgs(), tpi = 0; i != e; ++i) {
@@ -4164,9 +4163,6 @@
///
/// @param T The type that this routine is examining for completeness.
///
-/// @param PD The partial diagnostic that will be printed out if T is not a
-/// complete type.
-///
/// @returns @c true if @p T is incomplete and a diagnostic was emitted,
/// @c false otherwise.
bool Sema::RequireCompleteType(SourceLocation Loc, QualType T,
@@ -4362,7 +4358,7 @@
if (!I->getType()->isLiteralType() ||
I->getType().isVolatileQualified()) {
Diag(I->getLocation(), diag::note_non_literal_field)
- << RD << &*I << I->getType()
+ << RD << *I << I->getType()
<< I->getType().isVolatileQualified();
return true;
}
Modified: cfe/branches/tooling/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/TreeTransform.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/TreeTransform.h (original)
+++ cfe/branches/tooling/lib/Sema/TreeTransform.h Fri Jun 15 06:08:27 2012
@@ -224,9 +224,6 @@
/// \param Unexpanded The set of unexpanded parameter packs within the
/// pattern.
///
- /// \param NumUnexpanded The number of unexpanded parameter packs in
- /// \p Unexpanded.
- ///
/// \param ShouldExpand Will be set to \c true if the transformer should
/// expand the corresponding pack expansions into separate arguments. When
/// set, \c NumExpansions must also be set.
@@ -1179,7 +1176,17 @@
RParenLoc, MSAsm);
}
- /// \brief Build a new Objective-C @try statement.
+ /// \brief Build a new MS style inline asm statement.
+ ///
+ /// By default, performs semantic analysis to build the new statement.
+ /// Subclasses may override this routine to provide different behavior.
+ StmtResult RebuildMSAsmStmt(SourceLocation AsmLoc,
+ std::string &AsmString,
+ SourceLocation EndLoc) {
+ return getSema().ActOnMSAsmStmt(AsmLoc, AsmString, EndLoc);
+ }
+
+ /// \brief Build a new Objective-C \@try statement.
///
/// By default, performs semantic analysis to build the new statement.
/// Subclasses may override this routine to provide different behavior.
@@ -1203,7 +1210,7 @@
ExceptionDecl->getIdentifier());
}
- /// \brief Build a new Objective-C @catch statement.
+ /// \brief Build a new Objective-C \@catch statement.
///
/// By default, performs semantic analysis to build the new statement.
/// Subclasses may override this routine to provide different behavior.
@@ -1215,7 +1222,7 @@
Var, Body);
}
- /// \brief Build a new Objective-C @finally statement.
+ /// \brief Build a new Objective-C \@finally statement.
///
/// By default, performs semantic analysis to build the new statement.
/// Subclasses may override this routine to provide different behavior.
@@ -1224,7 +1231,7 @@
return getSema().ActOnObjCAtFinallyStmt(AtLoc, Body);
}
- /// \brief Build a new Objective-C @throw statement.
+ /// \brief Build a new Objective-C \@throw statement.
///
/// By default, performs semantic analysis to build the new statement.
/// Subclasses may override this routine to provide different behavior.
@@ -1233,7 +1240,7 @@
return getSema().BuildObjCAtThrowStmt(AtLoc, Operand);
}
- /// \brief Rebuild the operand to an Objective-C @synchronized statement.
+ /// \brief Rebuild the operand to an Objective-C \@synchronized statement.
///
/// By default, performs semantic analysis to build the new statement.
/// Subclasses may override this routine to provide different behavior.
@@ -1242,7 +1249,7 @@
return getSema().ActOnObjCAtSynchronizedOperand(atLoc, object);
}
- /// \brief Build a new Objective-C @synchronized statement.
+ /// \brief Build a new Objective-C \@synchronized statement.
///
/// By default, performs semantic analysis to build the new statement.
/// Subclasses may override this routine to provide different behavior.
@@ -1251,7 +1258,7 @@
return getSema().ActOnObjCAtSynchronizedStmt(AtLoc, Object, Body);
}
- /// \brief Build a new Objective-C @autoreleasepool statement.
+ /// \brief Build a new Objective-C \@autoreleasepool statement.
///
/// By default, performs semantic analysis to build the new statement.
/// Subclasses may override this routine to provide different behavior.
@@ -2261,7 +2268,7 @@
return getSema().BuildObjCDictionaryLiteral(Range, Elements, NumElements);
}
- /// \brief Build a new Objective-C @encode expression.
+ /// \brief Build a new Objective-C \@encode expression.
///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
@@ -5602,6 +5609,14 @@
S->isMSAsm());
}
+template<typename Derived>
+StmtResult
+TreeTransform<Derived>::TransformMSAsmStmt(MSAsmStmt *S) {
+ // No need to transform the asm string literal.
+ return getDerived().RebuildMSAsmStmt(S->getAsmLoc(),
+ *S->getAsmString(),
+ S->getEndLoc());
+}
template<typename Derived>
StmtResult
Modified: cfe/branches/tooling/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Serialization/ASTReader.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Serialization/ASTReader.cpp (original)
+++ cfe/branches/tooling/lib/Serialization/ASTReader.cpp Fri Jun 15 06:08:27 2012
@@ -829,7 +829,7 @@
Entries.push_back(LineEntry::get(FileOffset, LineNo, FilenameID,
FileKind, IncludeOffset));
}
- LineTable.AddEntry(FID, Entries);
+ LineTable.AddEntry(FileID::get(FID), Entries);
}
return false;
@@ -4144,7 +4144,6 @@
class clang::TypeLocReader : public TypeLocVisitor<TypeLocReader> {
ASTReader &Reader;
ModuleFile &F;
- llvm::BitstreamCursor &DeclsCursor;
const ASTReader::RecordData &Record;
unsigned &Idx;
@@ -4161,7 +4160,7 @@
public:
TypeLocReader(ASTReader &Reader, ModuleFile &F,
const ASTReader::RecordData &Record, unsigned &Idx)
- : Reader(Reader), F(F), DeclsCursor(F.DeclsCursor), Record(Record), Idx(Idx)
+ : Reader(Reader), F(F), Record(Record), Idx(Idx)
{ }
// We want compile-time assurance that we've enumerated all of
@@ -4859,7 +4858,6 @@
class DeclContextNameLookupVisitor {
ASTReader &Reader;
llvm::SmallVectorImpl<const DeclContext *> &Contexts;
- const DeclContext *DC;
DeclarationName Name;
SmallVectorImpl<NamedDecl *> &Decls;
@@ -4961,7 +4959,6 @@
class DeclContextAllNamesVisitor {
ASTReader &Reader;
llvm::SmallVectorImpl<const DeclContext *> &Contexts;
- const DeclContext *DC;
llvm::DenseMap<DeclarationName, SmallVector<NamedDecl *, 8> > &Decls;
public:
@@ -5058,7 +5055,7 @@
for (ObjCImplDecl::method_iterator
I = ImplD->meth_begin(), E = ImplD->meth_end(); I != E; ++I)
- Consumer->HandleInterestingDecl(DeclGroupRef(&*I));
+ Consumer->HandleInterestingDecl(DeclGroupRef(*I));
Consumer->HandleInterestingDecl(DeclGroupRef(ImplD));
}
@@ -5908,7 +5905,7 @@
case TemplateArgument::Integral: {
llvm::APSInt Value = ReadAPSInt(Record, Idx);
QualType T = readType(F, Record, Idx);
- return TemplateArgument(Value, T);
+ return TemplateArgument(Context, Value, T);
}
case TemplateArgument::Template:
return TemplateArgument(ReadTemplateName(F, Record, Idx));
Modified: cfe/branches/tooling/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Serialization/ASTReaderDecl.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/branches/tooling/lib/Serialization/ASTReaderDecl.cpp Fri Jun 15 06:08:27 2012
@@ -865,12 +865,11 @@
void ASTDeclReader::VisitFieldDecl(FieldDecl *FD) {
VisitDeclaratorDecl(FD);
- FD->setMutable(Record[Idx++]);
- int BitWidthOrInitializer = Record[Idx++];
- if (BitWidthOrInitializer == 1)
- FD->setBitWidth(Reader.ReadExpr(F));
- else if (BitWidthOrInitializer == 2)
- FD->setInClassInitializer(Reader.ReadExpr(F));
+ FD->Mutable = Record[Idx++];
+ if (int BitWidthOrInitializer = Record[Idx++]) {
+ FD->InitializerOrBitWidth.setInt(BitWidthOrInitializer - 1);
+ FD->InitializerOrBitWidth.setPointer(Reader.ReadExpr(F));
+ }
if (!FD->getDeclName()) {
if (FieldDecl *Tmpl = ReadDeclAs<FieldDecl>(Record, Idx))
Reader.getContext().setInstantiatedFromUnnamedFieldDecl(FD, Tmpl);
@@ -1095,11 +1094,7 @@
Data.HasTrivialDefaultConstructor = Record[Idx++];
Data.HasConstexprNonCopyMoveConstructor = Record[Idx++];
Data.DefaultedDefaultConstructorIsConstexpr = Record[Idx++];
- Data.DefaultedCopyConstructorIsConstexpr = Record[Idx++];
- Data.DefaultedMoveConstructorIsConstexpr = Record[Idx++];
Data.HasConstexprDefaultConstructor = Record[Idx++];
- Data.HasConstexprCopyConstructor = Record[Idx++];
- Data.HasConstexprMoveConstructor = Record[Idx++];
Data.HasTrivialCopyConstructor = Record[Idx++];
Data.HasTrivialMoveConstructor = Record[Idx++];
Data.HasTrivialCopyAssignment = Record[Idx++];
Modified: cfe/branches/tooling/lib/Serialization/ASTReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Serialization/ASTReaderStmt.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Serialization/ASTReaderStmt.cpp (original)
+++ cfe/branches/tooling/lib/Serialization/ASTReaderStmt.cpp Fri Jun 15 06:08:27 2012
@@ -317,6 +317,11 @@
Clobbers.data(), NumClobbers);
}
+void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
+ // FIXME: Statement reader not yet implemented for MS style inline asm.
+ VisitStmt(S);
+}
+
void ASTStmtReader::VisitExpr(Expr *E) {
VisitStmt(E);
E->setType(Reader.readType(F, Record, Idx));
Modified: cfe/branches/tooling/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Serialization/ASTWriter.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/branches/tooling/lib/Serialization/ASTWriter.cpp Fri Jun 15 06:08:27 2012
@@ -1242,15 +1242,14 @@
// Trait used for the on-disk hash table of header search information.
class HeaderFileInfoTrait {
ASTWriter &Writer;
- const HeaderSearch &HS;
// Keep track of the framework names we've used during serialization.
SmallVector<char, 128> FrameworkStringData;
llvm::StringMap<unsigned> FrameworkNameOffset;
public:
- HeaderFileInfoTrait(ASTWriter &Writer, const HeaderSearch &HS)
- : Writer(Writer), HS(HS) { }
+ HeaderFileInfoTrait(ASTWriter &Writer)
+ : Writer(Writer) { }
typedef const char *key_type;
typedef key_type key_type_ref;
@@ -1335,7 +1334,7 @@
if (FilesByUID.size() > HS.header_file_size())
FilesByUID.resize(HS.header_file_size());
- HeaderFileInfoTrait GeneratorTrait(*this, HS);
+ HeaderFileInfoTrait GeneratorTrait(*this);
OnDiskChainedHashTableGenerator<HeaderFileInfoTrait> Generator;
SmallVector<const char *, 4> SavedStrings;
unsigned NumHeaderSearchEntries = 0;
@@ -1605,11 +1604,11 @@
for (LineTableInfo::iterator L = LineTable.begin(), LEnd = LineTable.end();
L != LEnd; ++L) {
// Only emit entries for local files.
- if (L->first < 0)
+ if (L->first.ID < 0)
continue;
// Emit the file ID
- Record.push_back(L->first);
+ Record.push_back(L->first.ID);
// Emit the line entries
Record.push_back(L->second.size());
@@ -4148,7 +4147,7 @@
AddDeclRef(Arg.getAsDecl(), Record);
break;
case TemplateArgument::Integral:
- AddAPSInt(*Arg.getAsIntegral(), Record);
+ AddAPSInt(Arg.getAsIntegral(), Record);
AddTypeRef(Arg.getIntegralType(), Record);
break;
case TemplateArgument::Template:
@@ -4314,11 +4313,7 @@
Record.push_back(Data.HasTrivialDefaultConstructor);
Record.push_back(Data.HasConstexprNonCopyMoveConstructor);
Record.push_back(Data.DefaultedDefaultConstructorIsConstexpr);
- Record.push_back(Data.DefaultedCopyConstructorIsConstexpr);
- Record.push_back(Data.DefaultedMoveConstructorIsConstexpr);
Record.push_back(Data.HasConstexprDefaultConstructor);
- Record.push_back(Data.HasConstexprCopyConstructor);
- Record.push_back(Data.HasConstexprMoveConstructor);
Record.push_back(Data.HasTrivialCopyConstructor);
Record.push_back(Data.HasTrivialMoveConstructor);
Record.push_back(Data.HasTrivialCopyAssignment);
Modified: cfe/branches/tooling/lib/Serialization/ASTWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Serialization/ASTWriterDecl.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/branches/tooling/lib/Serialization/ASTWriterDecl.cpp Fri Jun 15 06:08:27 2012
@@ -626,11 +626,13 @@
void ASTDeclWriter::VisitFieldDecl(FieldDecl *D) {
VisitDeclaratorDecl(D);
Record.push_back(D->isMutable());
- Record.push_back(D->getBitWidth()? 1 : D->hasInClassInitializer() ? 2 : 0);
- if (D->getBitWidth())
- Writer.AddStmt(D->getBitWidth());
- else if (D->hasInClassInitializer())
- Writer.AddStmt(D->getInClassInitializer());
+ if (D->InitializerOrBitWidth.getInt() != ICIS_NoInit ||
+ D->InitializerOrBitWidth.getPointer()) {
+ Record.push_back(D->InitializerOrBitWidth.getInt() + 1);
+ Writer.AddStmt(D->InitializerOrBitWidth.getPointer());
+ } else {
+ Record.push_back(0);
+ }
if (!D->getDeclName())
Writer.AddDeclRef(Context.getInstantiatedFromUnnamedFieldDecl(D), Record);
Modified: cfe/branches/tooling/lib/Serialization/ASTWriterStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Serialization/ASTWriterStmt.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Serialization/ASTWriterStmt.cpp (original)
+++ cfe/branches/tooling/lib/Serialization/ASTWriterStmt.cpp Fri Jun 15 06:08:27 2012
@@ -249,6 +249,11 @@
Code = serialization::STMT_ASM;
}
+void ASTStmtWriter::VisitMSAsmStmt(MSAsmStmt *S) {
+ // FIXME: Statement writer not yet implemented for MS style inline asm.
+ VisitStmt(S);
+}
+
void ASTStmtWriter::VisitExpr(Expr *E) {
VisitStmt(E);
Writer.AddTypeRef(E->getType(), Record);
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp Fri Jun 15 06:08:27 2012
@@ -27,8 +27,10 @@
#include "clang/AST/DeclObjC.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprObjC.h"
+#include "clang/AST/StmtObjC.h"
#include "clang/AST/ASTContext.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringMap.h"
using namespace clang;
using namespace ento;
@@ -50,15 +52,34 @@
return 0;
}
-static bool isReceiverClassOrSuperclass(const ObjCInterfaceDecl *ID,
- StringRef ClassName) {
- if (ID->getIdentifier()->getName() == ClassName)
- return true;
+enum FoundationClass {
+ FC_None,
+ FC_NSArray,
+ FC_NSDictionary,
+ FC_NSEnumerator,
+ FC_NSOrderedSet,
+ FC_NSSet,
+ FC_NSString
+};
- if (const ObjCInterfaceDecl *Super = ID->getSuperClass())
- return isReceiverClassOrSuperclass(Super, ClassName);
+static FoundationClass findKnownClass(const ObjCInterfaceDecl *ID) {
+ static llvm::StringMap<FoundationClass> Classes;
+ if (Classes.empty()) {
+ Classes["NSArray"] = FC_NSArray;
+ Classes["NSDictionary"] = FC_NSDictionary;
+ Classes["NSEnumerator"] = FC_NSEnumerator;
+ Classes["NSOrderedSet"] = FC_NSOrderedSet;
+ Classes["NSSet"] = FC_NSSet;
+ Classes["NSString"] = FC_NSString;
+ }
+
+ // FIXME: Should we cache this at all?
+ FoundationClass result = Classes.lookup(ID->getIdentifier()->getName());
+ if (result == FC_None)
+ if (const ObjCInterfaceDecl *Super = ID->getSuperClass())
+ return findKnownClass(Super);
- return false;
+ return result;
}
static inline bool isNil(SVal X) {
@@ -106,7 +127,7 @@
if (!ID)
return;
- if (isReceiverClassOrSuperclass(ID, "NSString")) {
+ if (findKnownClass(ID) == FC_NSString) {
Selector S = msg.getSelector();
if (S.isUnarySelector())
@@ -517,50 +538,32 @@
// gains that this analysis gives.
const ObjCInterfaceDecl *Class = MD->getClassInterface();
- // -[NSArray initWithObjects:]
- if (isReceiverClassOrSuperclass(Class, "NSArray") &&
- S == initWithObjectsS)
- return true;
-
- // -[NSDictionary initWithObjectsAndKeys:]
- if (isReceiverClassOrSuperclass(Class, "NSDictionary") &&
- S == initWithObjectsAndKeysS)
- return true;
-
- // -[NSSet initWithObjects:]
- if (isReceiverClassOrSuperclass(Class, "NSSet") &&
- S == initWithObjectsS)
- return true;
-
- // -[NSOrderedSet initWithObjects:]
- if (isReceiverClassOrSuperclass(Class, "NSOrderedSet") &&
- S == initWithObjectsS)
- return true;
+ switch (findKnownClass(Class)) {
+ case FC_NSArray:
+ case FC_NSOrderedSet:
+ case FC_NSSet:
+ return S == initWithObjectsS;
+ case FC_NSDictionary:
+ return S == initWithObjectsAndKeysS;
+ default:
+ return false;
+ }
} else {
const ObjCInterfaceDecl *Class = msg.getReceiverInterface();
- // -[NSArray arrayWithObjects:]
- if (isReceiverClassOrSuperclass(Class, "NSArray") &&
- S == arrayWithObjectsS)
- return true;
-
- // -[NSDictionary dictionaryWithObjectsAndKeys:]
- if (isReceiverClassOrSuperclass(Class, "NSDictionary") &&
- S == dictionaryWithObjectsAndKeysS)
- return true;
-
- // -[NSSet setWithObjects:]
- if (isReceiverClassOrSuperclass(Class, "NSSet") &&
- S == setWithObjectsS)
- return true;
-
- // -[NSOrderedSet orderedSetWithObjects:]
- if (isReceiverClassOrSuperclass(Class, "NSOrderedSet") &&
- S == orderedSetWithObjectsS)
- return true;
+ switch (findKnownClass(Class)) {
+ case FC_NSArray:
+ return S == arrayWithObjectsS;
+ case FC_NSOrderedSet:
+ return S == orderedSetWithObjectsS;
+ case FC_NSSet:
+ return S == setWithObjectsS;
+ case FC_NSDictionary:
+ return S == dictionaryWithObjectsAndKeysS;
+ default:
+ return false;
+ }
}
-
- return false;
}
void VariadicMethodTypeChecker::checkPreObjCMessage(ObjCMessage msg,
@@ -648,6 +651,75 @@
}
//===----------------------------------------------------------------------===//
+// Improves the modeling of loops over Cocoa collections.
+//===----------------------------------------------------------------------===//
+
+namespace {
+class ObjCLoopChecker
+ : public Checker<check::PostStmt<ObjCForCollectionStmt> > {
+
+public:
+ void checkPostStmt(const ObjCForCollectionStmt *FCS, CheckerContext &C) const;
+};
+}
+
+static bool isKnownNonNilCollectionType(QualType T) {
+ const ObjCObjectPointerType *PT = T->getAs<ObjCObjectPointerType>();
+ if (!PT)
+ return false;
+
+ const ObjCInterfaceDecl *ID = PT->getInterfaceDecl();
+ if (!ID)
+ return false;
+
+ switch (findKnownClass(ID)) {
+ case FC_NSArray:
+ case FC_NSDictionary:
+ case FC_NSEnumerator:
+ case FC_NSOrderedSet:
+ case FC_NSSet:
+ return true;
+ default:
+ return false;
+ }
+}
+
+void ObjCLoopChecker::checkPostStmt(const ObjCForCollectionStmt *FCS,
+ CheckerContext &C) const {
+ ProgramStateRef State = C.getState();
+
+ // Check if this is the branch for the end of the loop.
+ SVal CollectionSentinel = State->getSVal(FCS, C.getLocationContext());
+ if (CollectionSentinel.isZeroConstant())
+ return;
+
+ // See if the collection is one where we /know/ the elements are non-nil.
+ const Expr *Collection = FCS->getCollection();
+ if (!isKnownNonNilCollectionType(Collection->getType()))
+ return;
+
+ // FIXME: Copied from ExprEngineObjC.
+ const Stmt *Element = FCS->getElement();
+ SVal ElementVar;
+ if (const DeclStmt *DS = dyn_cast<DeclStmt>(Element)) {
+ const VarDecl *ElemDecl = cast<VarDecl>(DS->getSingleDecl());
+ assert(ElemDecl->getInit() == 0);
+ ElementVar = State->getLValue(ElemDecl, C.getLocationContext());
+ } else {
+ ElementVar = State->getSVal(Element, C.getLocationContext());
+ }
+
+ if (!isa<Loc>(ElementVar))
+ return;
+
+ // Go ahead and assume the value is non-nil.
+ SVal Val = State->getSVal(cast<Loc>(ElementVar));
+ State = State->assume(cast<DefinedOrUnknownSVal>(Val), true);
+ C.addTransition(State);
+}
+
+
+//===----------------------------------------------------------------------===//
// Check registration.
//===----------------------------------------------------------------------===//
@@ -670,3 +742,7 @@
void ento::registerVariadicMethodTypeChecker(CheckerManager &mgr) {
mgr.registerChecker<VariadicMethodTypeChecker>();
}
+
+void ento::registerObjCLoopChecker(CheckerManager &mgr) {
+ mgr.registerChecker<ObjCLoopChecker>();
+}
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=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp Fri Jun 15 06:08:27 2012
@@ -128,14 +128,13 @@
public:
SmallVector<const FieldDecl *, 10> FieldChain;
private:
- ASTContext &C;
StoreManager &StoreMgr;
MemRegionManager &MrMgr;
Store store;
public:
- FindUninitializedField(ASTContext &c, StoreManager &storeMgr,
+ FindUninitializedField(StoreManager &storeMgr,
MemRegionManager &mrMgr, Store s)
- : C(c), StoreMgr(storeMgr), MrMgr(mrMgr), store(s) {}
+ : StoreMgr(storeMgr), MrMgr(mrMgr), store(s) {}
bool Find(const TypedValueRegion *R) {
QualType T = R->getValueType();
@@ -144,8 +143,8 @@
assert(RD && "Referred record has no definition");
for (RecordDecl::field_iterator I =
RD->field_begin(), E = RD->field_end(); I!=E; ++I) {
- const FieldRegion *FR = MrMgr.getFieldRegion(&*I, R);
- FieldChain.push_back(&*I);
+ const FieldRegion *FR = MrMgr.getFieldRegion(*I, R);
+ FieldChain.push_back(*I);
T = I->getType();
if (T->getAsStructureType()) {
if (Find(FR))
@@ -165,8 +164,7 @@
};
const LazyCompoundValData *D = LV->getCVData();
- FindUninitializedField F(C.getASTContext(),
- C.getState()->getStateManager().getStoreManager(),
+ FindUninitializedField F(C.getState()->getStateManager().getStoreManager(),
C.getSValBuilder().getRegionManager(),
D->getStore());
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp Fri Jun 15 06:08:27 2012
@@ -114,7 +114,7 @@
for (ObjCInterfaceDecl::ivar_iterator I=ID->ivar_begin(), E=ID->ivar_end();
I!=E; ++I) {
- ObjCIvarDecl *ID = &*I;
+ ObjCIvarDecl *ID = *I;
QualType T = ID->getType();
if (!T->isObjCObjectPointerType() ||
@@ -261,7 +261,7 @@
}
PathDiagnosticLocation SDLoc =
- PathDiagnosticLocation::createBegin(&*I, BR.getSourceManager());
+ PathDiagnosticLocation::createBegin(*I, BR.getSourceManager());
BR.EmitBasicReport(MD, name, categories::CoreFoundationObjectiveC,
os.str(), SDLoc);
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp Fri Jun 15 06:08:27 2012
@@ -94,7 +94,7 @@
///
/// check::Location
void checkLocation(SVal Loc, bool IsLoad, const Stmt *S,
- CheckerContext &C) const {}
+ CheckerContext &) const {}
/// \brief Called on binding of a value to a location.
///
@@ -103,7 +103,7 @@
/// \param S The bind is performed while processing the statement S.
///
/// check::Bind
- void checkBind(SVal Loc, SVal Val, const Stmt *S, CheckerContext &C) const {}
+ void checkBind(SVal Loc, SVal Val, const Stmt *S, CheckerContext &) const {}
/// \brief Called whenever a symbol becomes dead.
@@ -187,21 +187,23 @@
bool wantsRegionChangeUpdate(ProgramStateRef St) const { return true; }
- /// check::RegionChanges
- /// Allows tracking regions which get invalidated.
- /// \param state The current program state.
- /// \param invalidated A set of all symbols potentially touched by the change.
+ /// \brief Allows tracking regions which get invalidated.
+ ///
+ /// \param State The current program state.
+ /// \param Invalidated A set of all symbols potentially touched by the change.
/// \param ExplicitRegions The regions explicitly requested for invalidation.
/// For example, in the case of a function call, these would be arguments.
/// \param Regions The transitive closure of accessible regions,
/// i.e. all regions that may have been touched by this change.
- /// \param The call expression wrapper if the regions are invalidated by a
- /// call, 0 otherwise.
- /// Note, in order to be notified, the checker should also implement
+ /// \param Call The call expression wrapper if the regions are invalidated
+ /// by a call, 0 otherwise.
+ /// Note, in order to be notified, the checker should also implement the
/// wantsRegionChangeUpdate callback.
+ ///
+ /// check::RegionChanges
ProgramStateRef
checkRegionChanges(ProgramStateRef State,
- const StoreManager::InvalidatedSymbols *,
+ const StoreManager::InvalidatedSymbols *Invalidated,
ArrayRef<const MemRegion *> ExplicitRegions,
ArrayRef<const MemRegion *> Regions,
const CallOrObjCMessage *Call) const {
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=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/Checkers.td Fri Jun 15 06:08:27 2012
@@ -393,6 +393,10 @@
HelpText<"Check that 'self' is properly initialized inside an initializer method">,
DescFile<"ObjCSelfInitChecker.cpp">;
+def ObjCLoopChecker : Checker<"Loops">,
+ HelpText<"Improved modeling of loops using Cocoa collection types">,
+ DescFile<"BasicObjCFoundationChecks.cpp">;
+
def NSErrorChecker : Checker<"NSError">,
HelpText<"Check usage of NSError** parameters">,
DescFile<"NSErrorChecker.cpp">;
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp Fri Jun 15 06:08:27 2012
@@ -231,7 +231,7 @@
for (RecordDecl::field_iterator I = R->field_begin(), E = R->field_end();
I != E; ++I) {
ASTFieldVisitor walker(R, BR);
- walker.Visit(&*I);
+ walker.Visit(*I);
}
}
@@ -247,7 +247,7 @@
const RecordDecl *RD = RT->getDecl()->getDefinition();
for (RecordDecl::field_iterator I = RD->field_begin(), E = RD->field_end();
I != E; ++I)
- Visit(&*I);
+ Visit(*I);
}
FieldChain.pop_back();
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Fri Jun 15 06:08:27 2012
@@ -477,19 +477,27 @@
const CallExpr *CE,
SVal Size, SVal Init,
ProgramStateRef state) {
- // Get the return value.
- SVal retVal = state->getSVal(CE, C.getLocationContext());
+
+ // Bind the return value to the symbolic value from the heap region.
+ // TODO: We could rewrite post visit to eval call; 'malloc' does not have
+ // side effects other than what we model here.
+ unsigned Count = C.getCurrentBlockCount();
+ SValBuilder &svalBuilder = C.getSValBuilder();
+ const LocationContext *LCtx = C.getPredecessor()->getLocationContext();
+ DefinedSVal RetVal =
+ cast<DefinedSVal>(svalBuilder.getConjuredHeapSymbolVal(CE, LCtx, Count));
+ state = state->BindExpr(CE, C.getLocationContext(), RetVal);
// We expect the malloc functions to return a pointer.
- if (!isa<Loc>(retVal))
+ if (!isa<Loc>(RetVal))
return 0;
// Fill the region with the initialization value.
- state = state->bindDefault(retVal, Init);
+ state = state->bindDefault(RetVal, Init);
// Set the region's extent equal to the Size parameter.
const SymbolicRegion *R =
- dyn_cast_or_null<SymbolicRegion>(retVal.getAsRegion());
+ dyn_cast_or_null<SymbolicRegion>(RetVal.getAsRegion());
if (!R)
return 0;
if (isa<DefinedOrUnknownSVal>(Size)) {
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp Fri Jun 15 06:08:27 2012
@@ -118,11 +118,6 @@
Visit(E->getRHS());
}
- void VisitBinAdd(const BinaryOperator *E) {
- Visit(E->getLHS());
- Visit(E->getRHS());
- }
-
void VisitImplicitCastExpr(const ImplicitCastExpr *E) {
return Visit(E->getSubExpr());
}
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp Fri Jun 15 06:08:27 2012
@@ -85,7 +85,7 @@
// to an ivar.
for (ObjCImplementationDecl::propimpl_iterator I = ID->propimpl_begin(),
E = ID->propimpl_end(); I!=E; ++I)
- Scan(M, &*I);
+ Scan(M, *I);
// Scan the associated categories as well.
for (const ObjCCategoryDecl *CD =
@@ -118,7 +118,7 @@
for (ObjCInterfaceDecl::ivar_iterator I=ID->ivar_begin(),
E=ID->ivar_end(); I!=E; ++I) {
- const ObjCIvarDecl *ID = &*I;
+ const ObjCIvarDecl *ID = *I;
// Ignore ivars that...
// (a) aren't private
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Fri Jun 15 06:08:27 2012
@@ -1700,32 +1700,18 @@
};
class Leak : public CFRefBug {
- const bool isReturn;
- protected:
- Leak(StringRef name, bool isRet)
- : CFRefBug(name), isReturn(isRet) {
+ public:
+ Leak(StringRef name)
+ : CFRefBug(name) {
// Leaks should not be reported if they are post-dominated by a sink.
setSuppressOnSink(true);
}
- public:
const char *getDescription() const { return ""; }
bool isLeak() const { return true; }
};
- class LeakAtReturn : public Leak {
- public:
- LeakAtReturn(StringRef name)
- : Leak(name, true) {}
- };
-
- class LeakWithinFunction : public Leak {
- public:
- LeakWithinFunction(StringRef name)
- : Leak(name, false) {}
- };
-
//===---------===//
// Bug Reports. //
//===---------===//
@@ -2420,20 +2406,17 @@
bool GCEnabled) const {
if (GCEnabled) {
if (!leakWithinFunctionGC)
- leakWithinFunctionGC.reset(new LeakWithinFunction("Leak of object when "
- "using garbage "
- "collection"));
+ leakWithinFunctionGC.reset(new Leak("Leak of object when using "
+ "garbage collection"));
return leakWithinFunctionGC.get();
} else {
if (!leakWithinFunction) {
if (LOpts.getGC() == LangOptions::HybridGC) {
- leakWithinFunction.reset(new LeakWithinFunction("Leak of object when "
- "not using garbage "
- "collection (GC) in "
- "dual GC/non-GC "
- "code"));
+ leakWithinFunction.reset(new Leak("Leak of object when not using "
+ "garbage collection (GC) in "
+ "dual GC/non-GC code"));
} else {
- leakWithinFunction.reset(new LeakWithinFunction("Leak"));
+ leakWithinFunction.reset(new Leak("Leak"));
}
}
return leakWithinFunction.get();
@@ -2443,17 +2426,17 @@
CFRefBug *getLeakAtReturnBug(const LangOptions &LOpts, bool GCEnabled) const {
if (GCEnabled) {
if (!leakAtReturnGC)
- leakAtReturnGC.reset(new LeakAtReturn("Leak of returned object when "
- "using garbage collection"));
+ leakAtReturnGC.reset(new Leak("Leak of returned object when using "
+ "garbage collection"));
return leakAtReturnGC.get();
} else {
if (!leakAtReturn) {
if (LOpts.getGC() == LangOptions::HybridGC) {
- leakAtReturn.reset(new LeakAtReturn("Leak of returned object when "
- "not using garbage collection "
- "(GC) in dual GC/non-GC code"));
+ leakAtReturn.reset(new Leak("Leak of returned object when not using "
+ "garbage collection (GC) in dual "
+ "GC/non-GC code"));
} else {
- leakAtReturn.reset(new LeakAtReturn("Leak of returned object"));
+ leakAtReturn.reset(new Leak("Leak of returned object"));
}
}
return leakAtReturn.get();
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp Fri Jun 15 06:08:27 2012
@@ -46,7 +46,7 @@
visited. */
PostVisited /**< A CallExpr to this FunctionDecl is in the
worklist, and the body has been visited. */
- } K;
+ };
/// A DenseMap that records visited states of FunctionDecls.
llvm::DenseMap<const FunctionDecl *, Kind> VisitedFunctions;
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/AnalysisManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/AnalysisManager.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/AnalysisManager.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/AnalysisManager.cpp Fri Jun 15 06:08:27 2012
@@ -36,7 +36,7 @@
Ctx(ctx), Diags(diags), LangOpts(lang), PD(pd),
CreateStoreMgr(storemgr), CreateConstraintMgr(constraintmgr),
CheckerMgr(checkerMgr),
- AScope(ScopeDecl), MaxNodes(maxnodes), MaxVisit(maxvisit),
+ MaxNodes(maxnodes), MaxVisit(maxvisit),
VisualizeEGDot(vizdot), VisualizeEGUbi(vizubi), PurgeDead(purge),
EagerlyAssume(eager), TrimGraph(trim),
EagerlyTrimEGraph(eagerlyTrimEGraph),
@@ -59,7 +59,6 @@
CreateStoreMgr(ParentAM.CreateStoreMgr),
CreateConstraintMgr(ParentAM.CreateConstraintMgr),
CheckerMgr(ParentAM.CheckerMgr),
- AScope(ScopeDecl),
MaxNodes(ParentAM.MaxNodes),
MaxVisit(ParentAM.MaxVisit),
VisualizeEGDot(ParentAM.VisualizeEGDot),
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp Fri Jun 15 06:08:27 2012
@@ -670,6 +670,12 @@
Bldr.addNodes(Dst);
break;
+ case Stmt::MSAsmStmtClass:
+ Bldr.takeNodes(Pred);
+ VisitMSAsmStmt(cast<MSAsmStmt>(S), Pred, Dst);
+ Bldr.addNodes(Dst);
+ break;
+
case Stmt::BlockExprClass:
Bldr.takeNodes(Pred);
VisitBlockExpr(cast<BlockExpr>(S), Pred, Dst);
@@ -1813,6 +1819,12 @@
Bldr.generateNode(A, Pred, state);
}
+void ExprEngine::VisitMSAsmStmt(const MSAsmStmt *A, ExplodedNode *Pred,
+ ExplodedNodeSet &Dst) {
+ StmtNodeBuilder Bldr(Pred, Dst, *currentBuilderContext);
+ Bldr.generateNode(A, Pred, Pred->getState());
+}
+
//===----------------------------------------------------------------------===//
// Visualization.
//===----------------------------------------------------------------------===//
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp Fri Jun 15 06:08:27 2012
@@ -74,7 +74,6 @@
const Stmt *elem = S->getElement();
ProgramStateRef state = Pred->getState();
SVal elementV;
- StmtNodeBuilder Bldr(Pred, Dst, *currentBuilderContext);
if (const DeclStmt *DS = dyn_cast<DeclStmt>(elem)) {
const VarDecl *elemD = cast<VarDecl>(DS->getSingleDecl());
@@ -86,10 +85,11 @@
}
ExplodedNodeSet dstLocation;
- Bldr.takeNodes(Pred);
evalLocation(dstLocation, S, elem, Pred, state, elementV, NULL, false);
- Bldr.addNodes(dstLocation);
-
+
+ ExplodedNodeSet Tmp;
+ StmtNodeBuilder Bldr(Pred, Tmp, *currentBuilderContext);
+
for (ExplodedNodeSet::iterator NI = dstLocation.begin(),
NE = dstLocation.end(); NI!=NE; ++NI) {
Pred = *NI;
@@ -126,6 +126,10 @@
Bldr.generateNode(S, Pred, hasElems);
Bldr.generateNode(S, Pred, noElems);
}
+
+ // Finally, run any custom checkers.
+ // FIXME: Eventually all pre- and post-checks should live in VisitStmt.
+ getCheckerManager().runCheckersForPostStmt(Dst, Tmp, S, *this);
}
void ExprEngine::VisitObjCMessage(const ObjCMessage &msg,
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/MemRegion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/MemRegion.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/MemRegion.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/MemRegion.cpp Fri Jun 15 06:08:27 2012
@@ -518,10 +518,6 @@
os << "StaticGlobalsMemSpace{" << CR << '}';
}
-void NonStaticGlobalSpaceRegion::dumpToStream(raw_ostream &os) const {
- os << "NonStaticGlobalSpaceRegion";
-}
-
void GlobalInternalSpaceRegion::dumpToStream(raw_ostream &os) const {
os << "GlobalInternalSpaceRegion";
}
@@ -534,6 +530,22 @@
os << "GlobalImmutableSpaceRegion";
}
+void HeapSpaceRegion::dumpToStream(raw_ostream &os) const {
+ os << "HeapSpaceRegion";
+}
+
+void UnknownSpaceRegion::dumpToStream(raw_ostream &os) const {
+ os << "UnknownSpaceRegion";
+}
+
+void StackArgumentsSpaceRegion::dumpToStream(raw_ostream &os) const {
+ os << "StackArgumentsSpaceRegion";
+}
+
+void StackLocalsSpaceRegion::dumpToStream(raw_ostream &os) const {
+ os << "StackLocalsSpaceRegion";
+}
+
void MemRegion::dumpPretty(raw_ostream &os) const {
return;
}
@@ -837,6 +849,10 @@
return getSubRegion<SymbolicRegion>(sym, getUnknownRegion());
}
+const SymbolicRegion *MemRegionManager::getSymbolicHeapRegion(SymbolRef Sym) {
+ return getSubRegion<SymbolicRegion>(Sym, getHeapRegion());
+}
+
const FieldRegion*
MemRegionManager::getFieldRegion(const FieldDecl *d,
const MemRegion* superRegion){
@@ -1053,7 +1069,7 @@
unsigned idx = 0;
for (RecordDecl::field_iterator FI = RD->field_begin(),
FE = RD->field_end(); FI != FE; ++FI, ++idx)
- if (FR->getDecl() == &*FI)
+ if (FR->getDecl() == *FI)
break;
const ASTRecordLayout &Layout = getContext().getASTRecordLayout(RD);
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp Fri Jun 15 06:08:27 2012
@@ -489,6 +489,17 @@
o << " <key>issue_context</key>";
EmitString(o, declName) << '\n';
}
+
+ // Output the bug hash for issue unique-ing. Currently, it's just an
+ // offset from the beginning of the function.
+ if (const Stmt *Body = DeclWithIssue->getBody()) {
+ FullSourceLoc Loc(SM->getExpansionLoc(D->getLocation().asLocation()),
+ *SM);
+ FullSourceLoc FunLoc(SM->getExpansionLoc(Body->getLocStart()), *SM);
+ o << " <key>issue_hash</key><integer>"
+ << Loc.getExpansionLineNumber() - FunLoc.getExpansionLineNumber()
+ << "</integer>\n";
+ }
}
}
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/RegionStore.cpp Fri Jun 15 06:08:27 2012
@@ -1746,7 +1746,7 @@
continue;
QualType FTy = FI->getType();
- const FieldRegion* FR = MRMgr.getFieldRegion(&*FI, R);
+ const FieldRegion* FR = MRMgr.getFieldRegion(*FI, R);
if (FTy->isArrayType())
newStore = BindArray(newStore.getStore(), FR, *VI);
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/SValBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/SValBuilder.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/SValBuilder.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/SValBuilder.cpp Fri Jun 15 06:08:27 2012
@@ -148,6 +148,18 @@
return nonloc::SymbolVal(sym);
}
+DefinedOrUnknownSVal
+SValBuilder::getConjuredHeapSymbolVal(const Expr *E,
+ const LocationContext *LCtx,
+ unsigned VisitCount) {
+ QualType T = E->getType();
+ assert(Loc::isLocType(T));
+ assert(SymbolManager::canSymbolicate(T));
+
+ SymbolRef sym = SymMgr.getConjuredSymbol(E, LCtx, T, VisitCount);
+ return loc::MemRegionVal(MemMgr.getSymbolicHeapRegion(sym));
+}
+
DefinedSVal SValBuilder::getMetadataSymbolVal(const void *symbolTag,
const MemRegion *region,
const Expr *expr, QualType type,
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp Fri Jun 15 06:08:27 2012
@@ -673,11 +673,18 @@
// regions, though.
return UnknownVal();
- // If both values wrap regions, see if they're from different base regions.
+ const MemSpaceRegion *LeftMS = LeftMR->getMemorySpace();
+ const MemSpaceRegion *RightMS = RightMR->getMemorySpace();
+ const MemSpaceRegion *UnknownMS = MemMgr.getUnknownRegion();
const MemRegion *LeftBase = LeftMR->getBaseRegion();
const MemRegion *RightBase = RightMR->getBaseRegion();
- if (LeftBase != RightBase &&
- !isa<SymbolicRegion>(LeftBase) && !isa<SymbolicRegion>(RightBase)) {
+
+ // If the two regions are from different known memory spaces they cannot be
+ // equal. Also, assume that no symbolic region (whose memory space is
+ // unknown) is on the stack.
+ if (LeftMS != RightMS &&
+ ((LeftMS != UnknownMS && RightMS != UnknownMS) ||
+ (isa<StackSpaceRegion>(LeftMS) || isa<StackSpaceRegion>(RightMS)))) {
switch (op) {
default:
return UnknownVal();
@@ -688,24 +695,20 @@
}
}
- // The two regions are from the same base region. See if they're both a
- // type of region we know how to compare.
- const MemSpaceRegion *LeftMS = LeftBase->getMemorySpace();
- const MemSpaceRegion *RightMS = RightBase->getMemorySpace();
-
- // Heuristic: assume that no symbolic region (whose memory space is
- // unknown) is on the stack.
- // FIXME: we should be able to be more precise once we can do better
- // aliasing constraints for symbolic regions, but this is a reasonable,
- // albeit unsound, assumption that holds most of the time.
- if (isa<StackSpaceRegion>(LeftMS) ^ isa<StackSpaceRegion>(RightMS)) {
+ // If both values wrap regions, see if they're from different base regions.
+ // Note, heap base symbolic regions are assumed to not alias with
+ // each other; for example, we assume that malloc returns different address
+ // on each invocation.
+ if (LeftBase != RightBase &&
+ ((!isa<SymbolicRegion>(LeftBase) && !isa<SymbolicRegion>(RightBase)) ||
+ (isa<HeapSpaceRegion>(LeftMS) || isa<HeapSpaceRegion>(RightMS))) ){
switch (op) {
- default:
- break;
- case BO_EQ:
- return makeTruthVal(false, resultTy);
- case BO_NE:
- return makeTruthVal(true, resultTy);
+ default:
+ return UnknownVal();
+ case BO_EQ:
+ return makeTruthVal(false, resultTy);
+ case BO_NE:
+ return makeTruthVal(true, resultTy);
}
}
@@ -821,9 +824,9 @@
bool leftFirst = (op == BO_LT || op == BO_LE);
for (RecordDecl::field_iterator I = RD->field_begin(),
E = RD->field_end(); I!=E; ++I) {
- if (&*I == LeftFD)
+ if (*I == LeftFD)
return makeTruthVal(leftFirst, resultTy);
- if (&*I == RightFD)
+ if (*I == RightFD)
return makeTruthVal(!leftFirst, resultTy);
}
Propchange: cfe/branches/tooling/lib/Tooling/CompilationDatabase.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo (removed)
@@ -1,2 +0,0 @@
-/cfe/branches/type-system-rewrite/lib/Tooling/CompilationDatabase.cpp:134693-134817
-/cfe/trunk/test/SemaTemplate/lib/Tooling/CompilationDatabase.cpp:126920
Propchange: cfe/branches/tooling/lib/Tooling/Tooling.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo (removed)
@@ -1,2 +0,0 @@
-/cfe/branches/type-system-rewrite/lib/Tooling/Tooling.cpp:134693-134817
-/cfe/trunk/test/SemaTemplate/lib/Tooling/Tooling.cpp:126920
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=158515&r1=158514&r2=158515&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 Fri Jun 15 06:08:27 2012
@@ -3,16 +3,37 @@
#include "Common.h"
- at interface NSString : NSObject
--(id)string;
--(id)newString;
- at end
-
typedef const struct __CFString * CFStringRef;
typedef const void * CFTypeRef;
CFTypeRef CFBridgingRetain(id X);
id CFBridgingRelease(CFTypeRef);
+struct StrS {
+ CFStringRef sref_member;
+};
+
+ at interface NSString : NSObject {
+ CFStringRef sref;
+ struct StrS *strS;
+}
+-(id)string;
+-(id)newString;
+ at end
+
+ at implementation NSString
+-(id)string {
+ if (0)
+ return sref;
+ else
+ return strS->sref_member;
+}
+-(id)newString {
+ return sref; // expected-error {{implicit conversion of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'id' requires a bridged cast}} \
+ // expected-note{{use __bridge to convert directly (no change in ownership)}} \
+ // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}}
+}
+ at end
+
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}} \
Modified: cfe/branches/tooling/test/ARCMT/nonobjc-to-objc-cast.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/ARCMT/nonobjc-to-objc-cast.m?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/ARCMT/nonobjc-to-objc-cast.m (original)
+++ cfe/branches/tooling/test/ARCMT/nonobjc-to-objc-cast.m Fri Jun 15 06:08:27 2012
@@ -5,11 +5,6 @@
#include "Common.h"
- at interface NSString : NSObject
--(id)string;
--(id)newString;
- at end
-
typedef const struct __CFString * CFStringRef;
extern const CFStringRef kUTTypePlainText;
extern const CFStringRef kUTTypeRTF;
@@ -21,6 +16,18 @@
extern CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid);
+struct StrS {
+ CFStringRef sref_member;
+};
+
+ at interface NSString : NSObject {
+ CFStringRef sref;
+ struct StrS *strS;
+}
+-(id)string;
+-(id)newString;
+ at end
+
void f(BOOL b, id p) {
NSString *str = (NSString *)kUTTypePlainText;
str = b ? kUTTypeRTF : kUTTypePlainText;
@@ -41,6 +48,16 @@
}
@end
+ at implementation NSString
+-(id)string {
+ if (0)
+ return sref;
+ else
+ return strS->sref_member;
+}
+-(id)newString { return 0; }
+ at end
+
extern void consumeParam(CFStringRef CF_CONSUMED p);
void f2(NSString *s) {
Modified: cfe/branches/tooling/test/ARCMT/nonobjc-to-objc-cast.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/ARCMT/nonobjc-to-objc-cast.m.result?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/ARCMT/nonobjc-to-objc-cast.m.result (original)
+++ cfe/branches/tooling/test/ARCMT/nonobjc-to-objc-cast.m.result Fri Jun 15 06:08:27 2012
@@ -5,11 +5,6 @@
#include "Common.h"
- at interface NSString : NSObject
--(id)string;
--(id)newString;
- at end
-
typedef const struct __CFString * CFStringRef;
extern const CFStringRef kUTTypePlainText;
extern const CFStringRef kUTTypeRTF;
@@ -21,6 +16,18 @@
extern CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid);
+struct StrS {
+ CFStringRef sref_member;
+};
+
+ at interface NSString : NSObject {
+ CFStringRef sref;
+ struct StrS *strS;
+}
+-(id)string;
+-(id)newString;
+ at end
+
void f(BOOL b, id p) {
NSString *str = (__bridge NSString *)kUTTypePlainText;
str = (__bridge NSString *)(b ? kUTTypeRTF : kUTTypePlainText);
@@ -41,6 +48,16 @@
}
@end
+ at implementation NSString
+-(id)string {
+ if (0)
+ return (__bridge id)(sref);
+ else
+ return (__bridge id)(strS->sref_member);
+}
+-(id)newString { return 0; }
+ at end
+
extern void consumeParam(CFStringRef CF_CONSUMED p);
void f2(NSString *s) {
Modified: cfe/branches/tooling/test/Analysis/inline-plist.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/inline-plist.c?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/inline-plist.c (original)
+++ cfe/branches/tooling/test/Analysis/inline-plist.c Fri Jun 15 06:08:27 2012
@@ -274,6 +274,7 @@
// CHECK: <key>type</key><string>Division by zero</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>foo</string>
+// CHECK: <key>issue_hash</key><integer>4</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>14</integer>
@@ -396,6 +397,7 @@
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>has_bug</string>
+// CHECK: <key>issue_hash</key><integer>1</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>19</integer>
@@ -649,6 +651,7 @@
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>triggers_bug</string>
+// CHECK: <key>issue_hash</key><integer>1</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>27</integer>
@@ -945,6 +948,7 @@
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>test_block_ret</string>
+// CHECK: <key>issue_hash</key><integer>2</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>51</integer>
@@ -1058,6 +1062,7 @@
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>test_block_blockvar</string>
+// CHECK: <key>issue_hash</key><integer>3</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>57</integer>
@@ -1171,6 +1176,7 @@
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>test_block_arg</string>
+// CHECK: <key>issue_hash</key><integer>3</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>63</integer>
Modified: cfe/branches/tooling/test/Analysis/malloc-plist.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/malloc-plist.c?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/malloc-plist.c (original)
+++ cfe/branches/tooling/test/Analysis/malloc-plist.c Fri Jun 15 06:08:27 2012
@@ -364,6 +364,7 @@
// CHECK: <key>type</key><string>Memory leak</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>diagnosticTest</string>
+// CHECK: <key>issue_hash</key><integer>5</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>14</integer>
@@ -525,6 +526,7 @@
// CHECK: <key>type</key><string>Memory leak</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>myArrayAllocation</string>
+// CHECK: <key>issue_hash</key><integer>4</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>21</integer>
@@ -909,6 +911,7 @@
// CHECK: <key>type</key><string>Memory leak</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>reallocDiagnostics</string>
+// CHECK: <key>issue_hash</key><integer>5</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>28</integer>
@@ -1307,6 +1310,7 @@
// CHECK: <key>type</key><string>Memory leak</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>test_wrapper</string>
+// CHECK: <key>issue_hash</key><integer>3</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>45</integer>
@@ -1826,6 +1830,7 @@
// CHECK: <key>type</key><string>Use-after-free</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>test_double_action_call</string>
+// CHECK: <key>issue_hash</key><integer>3</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>61</integer>
@@ -2384,6 +2389,7 @@
// CHECK: <key>type</key><string>Memory leak</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>reallocIntra</string>
+// CHECK: <key>issue_hash</key><integer>3</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>76</integer>
@@ -2651,6 +2657,7 @@
// CHECK: <key>type</key><string>Memory leak</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>use_ret</string>
+// CHECK: <key>issue_hash</key><integer>3</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>86</integer>
@@ -2812,6 +2819,7 @@
// CHECK: <key>type</key><string>Memory leak</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>LeakedSymbol</string>
+// CHECK: <key>issue_hash</key><integer>8</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>97</integer>
@@ -3016,6 +3024,7 @@
// CHECK: <key>type</key><string>Memory leak</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>function_with_leak1</string>
+// CHECK: <key>issue_hash</key><integer>1</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>102</integer>
@@ -3220,6 +3229,7 @@
// CHECK: <key>type</key><string>Memory leak</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>function_with_leak2</string>
+// CHECK: <key>issue_hash</key><integer>2</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>111</integer>
@@ -3492,6 +3502,7 @@
// CHECK: <key>type</key><string>Memory leak</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>function_with_leak3</string>
+// CHECK: <key>issue_hash</key><integer>3</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>120</integer>
@@ -3764,6 +3775,7 @@
// CHECK: <key>type</key><string>Memory leak</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>function_with_leak4</string>
+// CHECK: <key>issue_hash</key><integer>5</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>131</integer>
@@ -3968,6 +3980,7 @@
// CHECK: <key>type</key><string>Memory leak</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>function_with_leak5</string>
+// CHECK: <key>issue_hash</key><integer>2</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>142</integer>
@@ -4172,6 +4185,7 @@
// CHECK: <key>type</key><string>Memory leak</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>function_with_leak6</string>
+// CHECK: <key>issue_hash</key><integer>2</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>153</integer>
@@ -4405,6 +4419,7 @@
// CHECK: <key>type</key><string>Memory leak</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>use_function_with_leak7</string>
+// CHECK: <key>issue_hash</key><integer>2</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>169</integer>
Modified: cfe/branches/tooling/test/Analysis/malloc-sizeof.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/malloc-sizeof.c?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/malloc-sizeof.c (original)
+++ cfe/branches/tooling/test/Analysis/malloc-sizeof.c Fri Jun 15 06:08:27 2012
@@ -10,13 +10,14 @@
struct A {};
struct B {};
-void foo() {
+void foo(unsigned int unsignedInt, unsigned int readSize) {
int *ip1 = malloc(sizeof(1));
int *ip2 = malloc(4 * sizeof(int));
long *lp1 = malloc(sizeof(short)); // expected-warning {{Result of 'malloc' is converted to a pointer of type 'long', which is incompatible with sizeof operand type 'short'}}
long *lp2 = malloc(5 * sizeof(double)); // expected-warning {{Result of 'malloc' is converted to a pointer of type 'long', which is incompatible with sizeof operand type 'double'}}
- long *lp3 = malloc(5 * sizeof(char) + 2); // expected-warning {{Result of 'malloc' is converted to a pointer of type 'long', which is incompatible with sizeof operand type 'char'}}
+ char *cp3 = malloc(5 * sizeof(char) + 2); // no warning
+ unsigned char *buf = malloc(readSize + sizeof(unsignedInt)); // no warning
struct A *ap1 = calloc(1, sizeof(struct A));
struct A *ap2 = calloc(2, sizeof(*ap1));
Modified: cfe/branches/tooling/test/Analysis/malloc.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/malloc.c?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/malloc.c (original)
+++ cfe/branches/tooling/test/Analysis/malloc.c Fri Jun 15 06:08:27 2012
@@ -1,6 +1,8 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.core.CastSize,unix.Malloc -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.core.CastSize,unix.Malloc,debug.ExprInspection -analyzer-store=region -verify %s
#include "system-header-simulator.h"
+void clang_analyzer_eval(int);
+
typedef __typeof(sizeof(int)) size_t;
void *malloc(size_t);
void *valloc(size_t);
@@ -839,10 +841,8 @@
return (cond ? mySub : myAdd)(x, x);
}
-// ----------------------------------------------------------------------------
-// Below are the known false positives.
+// Test anti-aliasing.
-// TODO: There should be no warning here. This one might be difficult to get rid of.
void dependsOnValueOfPtr(int *g, unsigned f) {
int *p;
@@ -855,10 +855,65 @@
if (p != g)
free(p);
else
- return; // expected-warning{{Memory is never released; potential leak}}
+ return; // no warning
return;
}
+int CMPRegionHeapToStack() {
+ int x = 0;
+ int *x1 = malloc(8);
+ int *x2 = &x;
+ clang_analyzer_eval(x1 == x2); // expected-warning{{FALSE}}
+ free(x1);
+ return x;
+}
+
+int CMPRegionHeapToHeap2() {
+ int x = 0;
+ int *x1 = malloc(8);
+ int *x2 = malloc(8);
+ int *x4 = x1;
+ int *x5 = x2;
+ clang_analyzer_eval(x4 == x5); // expected-warning{{FALSE}}
+ free(x1);
+ free(x2);
+ return x;
+}
+
+int CMPRegionHeapToHeap() {
+ int x = 0;
+ int *x1 = malloc(8);
+ int *x4 = x1;
+ if (x1 == x4) {
+ free(x1);
+ return 5/x; // expected-warning{{Division by zero}}
+ }
+ return x;// expected-warning{{This statement is never executed}}
+}
+
+int HeapAssignment() {
+ int m = 0;
+ int *x = malloc(4);
+ int *y = x;
+ *x = 5;
+ clang_analyzer_eval(*x != *y); // expected-warning{{FALSE}}
+ free(x);
+ return 0;
+}
+
+int *retPtr();
+int *retPtrMightAlias(int *x);
+int cmpHeapAllocationToUnknown() {
+ int zero = 0;
+ int *yBefore = retPtr();
+ int *m = malloc(8);
+ int *yAfter = retPtrMightAlias(m);
+ clang_analyzer_eval(yBefore == m); // expected-warning{{FALSE}}
+ clang_analyzer_eval(yAfter == m); // expected-warning{{FALSE}}
+ free(m);
+ return 0;
+}
+
// ----------------------------------------------------------------------------
// False negatives.
Modified: cfe/branches/tooling/test/Analysis/plist-output-alternate.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/plist-output-alternate.m?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/plist-output-alternate.m (original)
+++ cfe/branches/tooling/test/Analysis/plist-output-alternate.m Fri Jun 15 06:08:27 2012
@@ -137,6 +137,7 @@
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>test_null_init</string>
+// CHECK: <key>issue_hash</key><integer>2</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>6</integer>
@@ -216,6 +217,7 @@
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>test_null_assign</string>
+// CHECK: <key>issue_hash</key><integer>3</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>12</integer>
@@ -295,6 +297,7 @@
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>test_null_assign_transitive</string>
+// CHECK: <key>issue_hash</key><integer>4</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>19</integer>
@@ -437,6 +440,7 @@
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>test_null_cond</string>
+// CHECK: <key>issue_hash</key><integer>2</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>24</integer>
@@ -584,6 +588,7 @@
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>test_null_cond_transitive</string>
+// CHECK: <key>issue_hash</key><integer>3</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>31</integer>
@@ -697,6 +702,7 @@
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>test_null_field</string>
+// CHECK: <key>issue_hash</key><integer>3</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>38</integer>
@@ -960,6 +966,7 @@
// CHECK: <key>type</key><string>Leak</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>rdar8331641</string>
+// CHECK: <key>issue_hash</key><integer>6</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>58</integer>
Modified: cfe/branches/tooling/test/Analysis/plist-output.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/plist-output.m?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/plist-output.m (original)
+++ cfe/branches/tooling/test/Analysis/plist-output.m Fri Jun 15 06:08:27 2012
@@ -160,6 +160,7 @@
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>test_null_init</string>
+// CHECK: <key>issue_hash</key><integer>2</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>6</integer>
@@ -239,6 +240,7 @@
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>test_null_assign</string>
+// CHECK: <key>issue_hash</key><integer>3</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>12</integer>
@@ -318,6 +320,7 @@
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>test_null_assign_transitive</string>
+// CHECK: <key>issue_hash</key><integer>4</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>19</integer>
@@ -460,6 +463,7 @@
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>test_null_cond</string>
+// CHECK: <key>issue_hash</key><integer>2</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>24</integer>
@@ -607,6 +611,7 @@
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>test_null_cond_transitive</string>
+// CHECK: <key>issue_hash</key><integer>4</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>32</integer>
@@ -720,6 +725,7 @@
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>test_null_field</string>
+// CHECK: <key>issue_hash</key><integer>3</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>39</integer>
@@ -935,6 +941,7 @@
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>test_assumptions</string>
+// CHECK: <key>issue_hash</key><integer>8</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>51</integer>
@@ -1145,6 +1152,7 @@
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>issue_context_kind</key><string>function</string>
// CHECK: <key>issue_context</key><string>test_cond_assign</string>
+// CHECK: <key>issue_hash</key><integer>4</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>59</integer>
@@ -1326,6 +1334,7 @@
// CHECK: <key>type</key><string>Dereference of null pointer</string>
// CHECK: <key>issue_context_kind</key><string>Objective-C method</string>
// CHECK: <key>issue_context</key><string>test</string>
+// CHECK: <key>issue_hash</key><integer>3</integer>
// CHECK: <key>location</key>
// CHECK: <dict>
// CHECK: <key>line</key><integer>78</integer>
Propchange: cfe/branches/tooling/test/CMakeLists.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo (removed)
@@ -1,2 +0,0 @@
-/cfe/branches/type-system-rewrite/test/CMakeLists.txt:134693-134817
-/cfe/trunk/test/SemaTemplate/test/CMakeLists.txt:126920
Modified: cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp (original)
+++ cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp Fri Jun 15 06:08:27 2012
@@ -209,7 +209,7 @@
{}
};
-// - every assignment-expression that is an initializer-caluse appearing
+// - every assignment-expression that is an initializer-clause appearing
// directly or indirectly within a brace-or-equal-initializer for a non-static
// data member that is not named by a mem-initializer-id shall be a constant
// expression; and
@@ -224,6 +224,25 @@
constexpr X(int c) : a(c) {} // ok, b initialized by 2 * c + 1
};
+union XU1 { int a; constexpr XU1() = default; }; // expected-error{{not constexpr}}
+union XU2 { int a = 1; constexpr XU2() = default; };
+
+struct XU3 {
+ union {
+ int a;
+ };
+ constexpr XU3() = default; // expected-error{{not constexpr}}
+};
+struct XU4 {
+ union {
+ int a = 1;
+ };
+ constexpr XU4() = default;
+};
+
+static_assert(XU2().a == 1, "");
+static_assert(XU4().a == 1, "");
+
// - every implicit conversion used in converting a constructor argument to the
// corresponding parameter type and converting a full-expression to the
// corresponding member type shall be one of those allowed in a constant
@@ -247,3 +266,30 @@
int val;
};
}
+
+namespace CtorLookup {
+ // Ensure that we look up which constructor will actually be used.
+ struct A {
+ constexpr A(const A&) {}
+ A(A&) {}
+ constexpr A(int); // expected-note {{previous}}
+ };
+ constexpr A::A(int = 0) {} // expected-warning {{default constructor}}
+
+ struct B : A {
+ B() = default;
+ constexpr B(const B&);
+ constexpr B(B&);
+ };
+ constexpr B::B(const B&) = default;
+ constexpr B::B(B&) = default; // expected-error {{not constexpr}}
+
+ struct C {
+ A a;
+ C() = default;
+ constexpr C(const C&);
+ constexpr C(C&);
+ };
+ constexpr C::C(const C&) = default;
+ constexpr C::C(C&) = default; // expected-error {{not constexpr}}
+}
Modified: cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp (original)
+++ cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp Fri Jun 15 06:08:27 2012
@@ -64,5 +64,4 @@
using A = auto; // expected-error{{'auto' not allowed in type alias}}
-// FIXME: don't issue the second diagnostic for this error.
-auto k() -> auto; // expected-error{{'auto' not allowed in function return type}} unexpected-error{{without trailing return type}}
+auto k() -> auto; // expected-error{{'auto' not allowed in function return type}}
Modified: cfe/branches/tooling/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp (original)
+++ cfe/branches/tooling/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp Fri Jun 15 06:08:27 2012
@@ -167,6 +167,20 @@
Agg<short> ce1 = { Convert<int>(100000) }; // expected-error {{constant expression evaluates to 100000 which cannot be narrowed to type 'short'}} expected-note {{override}} expected-warning {{changes value from 100000 to -31072}}
Agg<char> ce2 = { ConvertVar<short>() }; // expected-error {{non-constant-expression cannot be narrowed from type 'short' to 'char'}} expected-note {{override}}
+
+ // Negative -> larger unsigned type.
+ unsigned long long ll1 = { -1 }; // expected-error {{cannot be narrowed}} expected-note {{override}}
+ unsigned long long ll2 = { 1 }; // OK
+ unsigned long long ll3 = { s }; // expected-error {{cannot be narrowed}} expected-note {{override}}
+ unsigned long long ll4 = { us }; // OK
+ unsigned long long ll5 = { ll }; // expected-error {{cannot be narrowed}} expected-note {{override}}
+ Agg<unsigned long long> ll6 = { -1 }; // expected-error {{cannot be narrowed}} expected-note {{override}}
+ Agg<unsigned long long> ll7 = { 18446744073709551615ULL }; // OK
+ Agg<unsigned long long> ll8 = { __int128(18446744073709551615ULL) + 1 }; // expected-error {{cannot be narrowed}} expected-note {{override}} expected-warning {{changes value}}
+ signed char c = 'x';
+ unsigned short usc1 = { c }; // expected-error {{cannot be narrowed}} expected-note {{override}}
+ unsigned short usc2 = { (signed char)'x' }; // OK
+ unsigned short usc3 = { (signed char)-1 }; // expected-error {{cannot be narrowed}} expected-note {{override}}
}
// Be sure that type- and value-dependent expressions in templates get the error
Modified: cfe/branches/tooling/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp (original)
+++ cfe/branches/tooling/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp Fri Jun 15 06:08:27 2012
@@ -4,4 +4,4 @@
// will necessarily be ill-formed as a trailing return type for a function
// definition), and recover with a "type cannot be defined in a trailing return
// type" error.
-auto j() -> enum { e3 }; // expected-error{{unnamed enumeration must be a definition}} expected-error {{expected a type}} expected-error {{without trailing return type}}
+auto j() -> enum { e3 }; // expected-error{{unnamed enumeration must be a definition}} expected-error {{expected a type}}
Modified: cfe/branches/tooling/test/CXX/special/class.copy/p13-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/special/class.copy/p13-0x.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/special/class.copy/p13-0x.cpp (original)
+++ cfe/branches/tooling/test/CXX/special/class.copy/p13-0x.cpp Fri Jun 15 06:08:27 2012
@@ -58,3 +58,59 @@
struct Constexpr5 : Constexpr5Base { constexpr Constexpr5() {} };
constexpr Constexpr5 ce5move = Constexpr5();
constexpr Constexpr5 ce5copy = ce5move;
+
+// An explicitly-defaulted constructor doesn't become constexpr until the end of
+// its class. Make sure we note that the class has a constexpr constructor when
+// that happens.
+namespace PR13052 {
+ template<typename T> struct S {
+ S() = default; // expected-note 2{{here}}
+ S(S&&) = default;
+ S(const S&) = default;
+ T t;
+ };
+
+ struct U {
+ U() = default;
+ U(U&&) = default;
+ U(const U&) = default;
+ };
+
+ struct V {
+ V(); // expected-note {{here}}
+ V(V&&) = default;
+ V(const V&) = default;
+ };
+
+ struct W {
+ W(); // expected-note {{here}}
+ };
+
+ static_assert(__is_literal_type(U), "");
+ static_assert(!__is_literal_type(V), "");
+ static_assert(!__is_literal_type(W), "");
+ static_assert(__is_literal_type(S<U>), "");
+ static_assert(!__is_literal_type(S<V>), "");
+ static_assert(!__is_literal_type(S<W>), "");
+
+ struct X {
+ friend constexpr U::U() noexcept;
+ friend constexpr U::U(U&&) noexcept;
+ friend constexpr U::U(const U&) noexcept;
+ friend constexpr V::V(); // expected-error {{follows non-constexpr declaration}}
+ friend constexpr V::V(V&&) noexcept;
+ friend constexpr V::V(const V&) noexcept;
+ friend constexpr W::W(); // expected-error {{follows non-constexpr declaration}}
+ friend constexpr W::W(W&&) noexcept;
+ friend constexpr W::W(const W&) noexcept;
+ friend constexpr S<U>::S() noexcept;
+ friend constexpr S<U>::S(S<U>&&) noexcept;
+ friend constexpr S<U>::S(const S<U>&) noexcept;
+ friend constexpr S<V>::S(); // expected-error {{follows non-constexpr declaration}}
+ friend constexpr S<V>::S(S<V>&&) noexcept;
+ friend constexpr S<V>::S(const S<V>&) noexcept;
+ friend constexpr S<W>::S(); // expected-error {{follows non-constexpr declaration}}
+ friend constexpr S<W>::S(S<W>&&) noexcept;
+ friend constexpr S<W>::S(const S<W>&) noexcept;
+ };
+}
Modified: cfe/branches/tooling/test/CXX/special/class.copy/p8-cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/special/class.copy/p8-cxx11.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/special/class.copy/p8-cxx11.cpp (original)
+++ cfe/branches/tooling/test/CXX/special/class.copy/p8-cxx11.cpp Fri Jun 15 06:08:27 2012
@@ -43,6 +43,6 @@
friend C::C(C &);
friend D::D(const D &);
friend E::E(E &);
- friend F::F(const F &);
+ constexpr friend F::F(const F &);
friend G::G(G &);
};
Modified: cfe/branches/tooling/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp (original)
+++ cfe/branches/tooling/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp Fri Jun 15 06:08:27 2012
@@ -1,10 +1,14 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
namespace N {
- template<class T> class X;
+ template<class T> class X; // expected-note {{'N::X' declared here}} \
+ // expected-note {{explicitly specialized declaration is here}}
}
-template<> class X<int> { /* ... */ }; // expected-error {{non-template class 'X'}}
+// TODO: Don't add a namespace qualifier to the template if it would trigger
+// the warning about the specialization being outside of the namespace.
+template<> class X<int> { /* ... */ }; // expected-error {{no template named 'X'; did you mean 'N::X'?}} \
+ // expected-warning {{first declaration of class template specialization of 'X' outside namespace 'N' is a C++11 extension}}
namespace N {
Removed: cfe/branches/tooling/test/CodeGen/2002-05-24-Alloca.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/2002-05-24-Alloca.c?rev=158514&view=auto
==============================================================================
--- cfe/branches/tooling/test/CodeGen/2002-05-24-Alloca.c (original)
+++ cfe/branches/tooling/test/CodeGen/2002-05-24-Alloca.c (removed)
@@ -1,11 +0,0 @@
-// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
-
-typedef __SIZE_TYPE__ size_t;
-void *alloca(size_t size);
-char *strcpy(char *restrict s1, const char *restrict s2);
-int puts(const char *s);
-int main(int argc, char **argv) {
- char *C = (char*)alloca(argc);
- strcpy(C, argv[0]);
- puts(C);
-}
Modified: cfe/branches/tooling/test/CodeGen/vla.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/vla.c?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/vla.c (original)
+++ cfe/branches/tooling/test/CodeGen/vla.c Fri Jun 15 06:08:27 2012
@@ -142,3 +142,52 @@
// CHECK-NEXT: ret i32 [[T7]]
return p2 - p;
}
+
+// rdar://11485774
+void test5(void)
+{
+ // CHECK: define void @test5(
+ int a[5], i = 0;
+ // CHECK: [[A:%.*]] = alloca [5 x i32], align 4
+ // CHECK-NEXT: [[I:%.*]] = alloca i32, align 4
+ // CHECK-NEXT: [[CL:%.*]] = alloca i32*, align 4
+ // CHECK-NEXT: store i32 0, i32* [[I]], align 4
+
+ (typeof(++i, (int (*)[i])a)){&a} += 0;
+ // CHECK-NEXT: [[Z:%.*]] = load i32* [[I]], align 4
+ // CHECK-NEXT: [[INC:%.*]] = add nsw i32 [[Z]], 1
+ // CHECK-NEXT: store i32 [[INC]], i32* [[I]], align 4
+ // CHECK-NEXT: [[O:%.*]] = load i32* [[I]], align 4
+ // CHECK-NEXT: [[AR:%.*]] = getelementptr inbounds [5 x i32]* [[A]], i32 0, i32 0
+ // CHECK-NEXT: [[T:%.*]] = bitcast [5 x i32]* [[A]] to i32*
+ // CHECK-NEXT: store i32* [[T]], i32** [[CL]]
+ // CHECK-NEXT: [[TH:%.*]] = load i32** [[CL]]
+ // CHECK-NEXT: [[VLAIX:%.*]] = mul nsw i32 0, [[O]]
+ // CHECK-NEXT: [[ADDPTR:%.*]] = getelementptr inbounds i32* [[TH]], i32 [[VLAIX]]
+ // CHECK-NEXT: store i32* [[ADDPTR]], i32** [[CL]]
+}
+
+void test6(void)
+{
+ // CHECK: define void @test6(
+ int n = 20, **a, i=0;
+ // CHECK: [[N:%.*]] = alloca i32, align 4
+ // CHECK-NEXT: [[A:%.*]] = alloca i32**, align 4
+ // CHECK-NEXT: [[I:%.*]] = alloca i32, align 4
+ (int (**)[i]){&a}[0][1][5] = 0;
+ // CHECK-NEXT: [[CL:%.*]] = alloca i32**, align 4
+ // CHECK-NEXT: store i32 20, i32* [[N]], align 4
+ // CHECK-NEXT: store i32 0, i32* [[I]], align 4
+ // CHECK-NEXT: [[Z:%.*]] = load i32* [[I]], align 4
+ // CHECK-NEXT: [[O:%.*]] = bitcast i32*** [[A]] to i32**
+ // CHECK-NEXT: store i32** [[O]], i32*** [[CL]]
+ // CHECK-NEXT: [[T:%.*]] = load i32*** [[CL]]
+ // CHECK-NEXT: [[IX:%.*]] = getelementptr inbounds i32** [[T]], i32 0
+ // CHECK-NEXT: [[TH:%.*]] = load i32** [[IX]], align 4
+ // CHECK-NEXT: [[F:%.*]] = mul nsw i32 1, [[Z]]
+ // CHECK-NEXT: [[IX1:%.*]] = getelementptr inbounds i32* [[TH]], i32 [[F]]
+ // CHECK-NEXT: [[IX2:%.*]] = getelementptr inbounds i32* [[IX1]], i32 5
+ // CHECK-NEXT: store i32 0, i32* [[IX2]], align 4
+}
+
+
Modified: cfe/branches/tooling/test/CodeGenCXX/exceptions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/exceptions.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/exceptions.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/exceptions.cpp Fri Jun 15 06:08:27 2012
@@ -414,3 +414,39 @@
// CHECK: [[TEST9_NEW:%.*]] = call noalias i8* @_Znam
// CHECK: call void @_ZdaPv(i8* [[TEST9_NEW]])
}
+
+// In a destructor with a function-try-block, a return statement in a
+// catch handler behaves differently from running off the end of the
+// catch handler. PR13102.
+namespace test10 {
+ extern void cleanup();
+ extern bool suppress;
+
+ struct A { ~A(); };
+ A::~A() try { cleanup(); } catch (...) { return; }
+ // CHECK: define void @_ZN6test101AD1Ev(
+ // CHECK: invoke void @_ZN6test107cleanupEv()
+ // CHECK-NOT: rethrow
+ // CHECK: ret void
+
+ struct B { ~B(); };
+ B::~B() try { cleanup(); } catch (...) {}
+ // CHECK: define void @_ZN6test101BD1Ev(
+ // CHECK: invoke void @_ZN6test107cleanupEv()
+ // CHECK: call i8* @__cxa_begin_catch
+ // CHECK-NEXT: invoke void @__cxa_rethrow()
+ // CHECK: unreachable
+
+ struct C { ~C(); };
+ C::~C() try { cleanup(); } catch (...) { if (suppress) return; }
+ // CHECK: define void @_ZN6test101CD1Ev(
+ // CHECK: invoke void @_ZN6test107cleanupEv()
+ // CHECK: call i8* @__cxa_begin_catch
+ // CHECK-NEXT: load i8* @_ZN6test108suppressE, align 1
+ // CHECK-NEXT: trunc
+ // CHECK-NEXT: br i1
+ // CHECK: call void @__cxa_end_catch()
+ // CHECK-NEXT: br label
+ // CHECK: invoke void @__cxa_rethrow()
+ // CHECK: unreachable
+}
Modified: cfe/branches/tooling/test/CodeGenCXX/mangle-ms.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/mangle-ms.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/mangle-ms.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/mangle-ms.cpp Fri Jun 15 06:08:27 2012
@@ -12,6 +12,9 @@
// CHECK: @"\01?j@@3P6GHCE at ZA"
// CHECK: @"\01?k@@3PTfoo@@DA"
// CHECK: @"\01?l@@3P8foo@@AEHH at ZA"
+// CHECK: @"\01?color1@@3PANA"
+// CHECK: @"\01?color2@@3PBNA"
+// CHECK: @"\01?color3@@3PBY02NA"
int a;
@@ -41,6 +44,8 @@
//CHECK: @"\01??0foo@@QAE at PAD@Z"
}f,s1(1),s2((char*)0);
+typedef foo (foo2);
+
struct bar {
static int g;
};
@@ -72,9 +77,9 @@
int (__stdcall *j)(signed char, unsigned char);
-const volatile char foo::*k;
+const volatile char foo2::*k;
-int (foo::*l)(int);
+int (foo2::*l)(int);
// Static functions are mangled, too.
// Also make sure calling conventions, arglists, and throw specs work.
@@ -121,3 +126,9 @@
void (redundant_parens)();
void redundant_parens_use() { redundant_parens(); }
// CHECK: @"\01?redundant_parens@@YAXXZ"
+
+// PR13047
+typedef double RGB[3];
+RGB color1;
+extern const RGB color2 = {};
+extern RGB const ((color3)[5]) = {};
Modified: cfe/branches/tooling/test/CodeGenCXX/visibility.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/visibility.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/visibility.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/visibility.cpp Fri Jun 15 06:08:27 2012
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fvisibility hidden -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-HIDDEN
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -fvisibility hidden -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-HIDDEN
#define HIDDEN __attribute__((visibility("hidden")))
#define PROTECTED __attribute__((visibility("protected")))
@@ -79,6 +79,25 @@
// CHECK-HIDDEN: @_ZN6test413barE = external hidden global
}
+namespace test48 {
+ // Test that we use the visibility of struct foo when instantiating the
+ // template. Note that is a case where we disagree with gcc, it produces
+ // a default symbol.
+ struct HIDDEN foo {
+ };
+ DEFAULT foo x;
+
+ struct bar {
+ template<foo *z>
+ struct zed {
+ };
+ };
+
+ bar::zed<&x> y;
+ // CHECK: _ZN6test481yE = hidden global
+ // CHECK-HIDDEN: _ZN6test481yE = hidden global
+}
+
// CHECK: @_ZN5Test425VariableInHiddenNamespaceE = hidden global i32 10
// CHECK: @_ZN5Test71aE = hidden global
// CHECK: @_ZN5Test71bE = global
@@ -881,3 +900,77 @@
// CHECK: define internal void @_ZN6test473foo3barINS_12_GLOBAL__N_13zedEEEvv
// CHECK-HIDDEN: define internal void @_ZN6test473foo3barINS_12_GLOBAL__N_13zedEEEvv
}
+
+namespace test49 {
+ // Test that we use the visibility of struct foo when instantiating the
+ // template. Note that is a case where we disagree with gcc, it produces
+ // a default symbol.
+
+ struct HIDDEN foo {
+ };
+
+ DEFAULT foo x;
+
+ struct bar {
+ template<foo *z>
+ void zed() {
+ }
+ };
+
+ template void bar::zed<&x>();
+ // CHECK: define weak_odr hidden void @_ZN6test493bar3zedIXadL_ZNS_1xEEEEEvv
+ // CHECK-HIDDEN: define weak_odr hidden void @_ZN6test493bar3zedIXadL_ZNS_1xEEEEEvv
+}
+
+namespace test50 {
+ // Test that we use the visibility of struct foo when instantiating the
+ // template. Note that is a case where we disagree with gcc, it produces
+ // a default symbol.
+
+ struct HIDDEN foo {
+ };
+ DEFAULT foo x;
+ template<foo *z>
+ struct DEFAULT bar {
+ void zed() {
+ }
+ };
+ template void bar<&x>::zed();
+ // CHECK: define weak_odr hidden void @_ZN6test503barIXadL_ZNS_1xEEEE3zedEv
+ // CHECK-HIDDEN: define weak_odr hidden void @_ZN6test503barIXadL_ZNS_1xEEEE3zedEv
+}
+
+namespace test51 {
+ // Test that we use the visibility of struct foo when instantiating the
+ // template. Note that is a case where we disagree with gcc, it produces
+ // a default symbol.
+
+ struct HIDDEN foo {
+ };
+ DEFAULT foo x;
+ template<foo *z>
+ void DEFAULT zed() {
+ }
+ template void zed<&x>();
+ // CHECK: define weak_odr hidden void @_ZN6test513zedIXadL_ZNS_1xEEEEEvv
+ // CHECK-HIDDEN: define weak_odr hidden void @_ZN6test513zedIXadL_ZNS_1xEEEEEvv
+}
+
+namespace test52 {
+ // Test that we use the linkage of struct foo when instantiating the
+ // template. Note that is a case where we disagree with gcc, it produces
+ // an external symbol.
+
+ namespace {
+ struct foo {
+ };
+ }
+ template<foo *x>
+ void zed() {
+ }
+ void f() {
+ zed<nullptr>();
+ }
+ // CHECK: define internal void @_ZN6test523zedILPNS_12_GLOBAL__N_13fooE0EEEvv
+ // CHECK-HIDDEN: define internal void @_ZN6test523zedILPNS_12_GLOBAL__N_13fooE0EEEvv
+}
Modified: cfe/branches/tooling/test/Driver/clang-translation.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/clang-translation.c?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/clang-translation.c (original)
+++ cfe/branches/tooling/test/Driver/clang-translation.c Fri Jun 15 06:08:27 2012
@@ -51,3 +51,26 @@
// ARMV5E: clang
// ARMV5E: "-cc1"
// ARMV5E: "-target-cpu" "arm1022e"
+
+// RUN: %clang -ccc-clang-archs powerpc64 \
+// RUN: -target powerpc64-unknown-linux-gnu -### -S %s 2> %t.log \
+// RUN: -mcpu=G5
+// RUN: FileCheck -check-prefix=PPCG5 %s < %t.log
+// PPCG5: clang
+// PPCG5: "-cc1"
+// PPCG5: "-target-cpu" "g5"
+
+// RUN: %clang -ccc-clang-archs powerpc64 \
+// RUN: -target powerpc64-unknown-linux-gnu -### -S %s 2> %t.log \
+// RUN: -mcpu=power7
+// RUN: FileCheck -check-prefix=PPCPWR7 %s < %t.log
+// PPCPWR7: clang
+// PPCPWR7: "-cc1"
+// PPCPWR7: "-target-cpu" "pwr7"
+
+// RUN: %clang -ccc-clang-archs powerpc64 \
+// RUN: -target powerpc64-unknown-linux-gnu -### -S %s 2> %t.log
+// RUN: FileCheck -check-prefix=PPC64NS %s < %t.log
+// PPC64NS: clang
+// PPC64NS: "-cc1"
+// PPC64NS: "-target-cpu" "ppc64"
Modified: cfe/branches/tooling/test/Driver/warning-options.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/warning-options.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/warning-options.cpp (original)
+++ cfe/branches/tooling/test/Driver/warning-options.cpp Fri Jun 15 06:08:27 2012
@@ -8,3 +8,11 @@
// CHECK: unknown warning option '-Wmonkey'
// CHECK: unknown warning option '-Wno-monkey'
// CHECK: unknown warning option '-Wno-unused-command-line-arguments'; did you mean '-Wno-unused-command-line-argument'?
+
+// RUN: %clang -### -pedantic -no-pedantic %s 2>&1 | FileCheck -check-prefix=NO_PEDANTIC %s
+// NO_PEDANTIC-NOT: -pedantic
+// RUN: %clang -### -pedantic -pedantic -no-pedantic -pedantic %s 2>&1 | FileCheck -check-prefix=PEDANTIC %s
+// PEDANTIC: -pedantic
+
+// PR12920: They use gcc driver. Clang tends to pass -pedantic to gcc-as and gcc-ld.
+// XFAIL: cygwin,mingw32
Modified: cfe/branches/tooling/test/FixIt/fixit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/FixIt/fixit.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/FixIt/fixit.cpp (original)
+++ cfe/branches/tooling/test/FixIt/fixit.cpp Fri Jun 15 06:08:27 2012
@@ -54,7 +54,7 @@
}
namespace rdar7796492 {
- class A { int x, y; A(); };
+ struct A { int x, y; A(); };
A::A()
: x(1) y(2) { // expected-error{{missing ',' between base or member initializers}}
@@ -242,3 +242,21 @@
}
} // namespace arrow_suggest
+
+// Make sure fixing namespace-qualified identifiers functions properly with
+// namespace-aware typo correction/
+namespace redecl_typo {
+namespace Foo {
+ void BeEvil(); // expected-note {{'BeEvil' declared here}}
+}
+namespace Bar {
+ namespace Foo {
+ bool isGood(); // expected-note {{'Bar::Foo::isGood' declared here}}
+ void beEvil();
+ }
+}
+bool Foo::isGood() { // expected-error {{out-of-line definition of 'isGood' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'Bar::Foo::isGood'?}}
+ return true;
+}
+void Foo::beEvil() {} // expected-error {{out-of-line definition of 'beEvil' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'BeEvil'?}}
+}
Modified: cfe/branches/tooling/test/FixIt/objc-literals.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/FixIt/objc-literals.m?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/FixIt/objc-literals.m (original)
+++ cfe/branches/tooling/test/FixIt/objc-literals.m Fri Jun 15 06:08:27 2012
@@ -2,13 +2,15 @@
// RUN: cp %s %t
// RUN: not %clang_cc1 -fsyntax-only -fixit -x objective-c %t
// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x objective-c %t
-// RUN: grep arrayWithObjects %t
+// RUN: FileCheck -input-file=%t %s
typedef unsigned char BOOL;
- at interface NSNumber @end
+ at interface NSObject
+- (BOOL)isEqual:(id)other;
+ at end
- at interface NSNumber (NSNumberCreation)
+ at interface NSNumber : NSObject
+ (NSNumber *)numberWithChar:(char)value;
+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
+ (NSNumber *)numberWithShort:(short)value;
@@ -24,17 +26,17 @@
+ (NSNumber *)numberWithBool:(BOOL)value;
@end
- at interface NSArray
- at end
-
- at interface NSArray (NSArrayCreation)
+ at interface NSArray : NSObject
+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
@end
- at interface NSDictionary
+ at interface NSDictionary : NSObject
+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
@end
+ at interface NSString : NSObject
+ at end
+
void fixes() {
id arr = @[
17, // expected-error{{numeric literal must be prefixed by '@' in a collection}}
@@ -42,3 +44,23 @@
"blah" // expected-error{{string literal must be prefixed by '@'}}
];
}
+
+void testComparisons(id obj) {
+ if (obj == @"abc") return; // expected-error{{direct comparison of a string literal is not allowed; use -isEqual: instead}}
+ if (obj != @"def") return; // expected-error{{direct comparison of a string literal is not allowed; use -isEqual: instead}}
+ if (@"ghi" == obj) return; // expected-error{{direct comparison of a string literal is not allowed; use -isEqual: instead}}
+
+ // CHECK: void testComparisons(id obj) {
+ // Make sure these three substitutions aren't matching the CHECK lines.
+ // CHECK-NEXT: if ([obj isEqual: @"abc"]) return;
+ // CHECK-NEXT: if (![obj isEqual: @"def"]) return;
+ // CHECK-NEXT: if ([@"ghi" isEqual: obj]) return;
+
+ if (@[] == obj) return; // expected-error{{direct comparison of an array literal is not allowed; use -isEqual: instead}}
+ if (@{} == obj) return; // expected-error{{direct comparison of a dictionary literal is not allowed; use -isEqual: instead}}
+ if (@12 == obj) return; // expected-error{{direct comparison of a numeric literal is not allowed; use -isEqual: instead}}
+ if (@1.0 == obj) return; // expected-error{{direct comparison of a numeric literal is not allowed; use -isEqual: instead}}
+ if (@__objc_yes == obj) return; // expected-error{{direct comparison of a numeric literal is not allowed; use -isEqual: instead}}
+ if (@(1+1) == obj) return; // expected-error{{direct comparison of a boxed expression is not allowed; use -isEqual: instead}}
+}
+
Modified: cfe/branches/tooling/test/Index/complete-method-decls.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/complete-method-decls.m?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/complete-method-decls.m (original)
+++ cfe/branches/tooling/test/Index/complete-method-decls.m Fri Jun 15 06:08:27 2012
@@ -8,7 +8,7 @@
- (int)getInt;
- (id)getSelf;
@end
-
+ at protocol P1;
@protocol P2<P1>
+ (id)alloc;
@end
Modified: cfe/branches/tooling/test/Index/complete-properties.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/complete-properties.m?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/complete-properties.m (original)
+++ cfe/branches/tooling/test/Index/complete-properties.m Fri Jun 15 06:08:27 2012
@@ -45,6 +45,17 @@
@synthesize Prop2 = Prop2_;
@end
+ at protocol P1
+ at property int Prop5;
+ at end
+
+ at class P1;
+
+ at interface I5<P1>
+ at end
+ at implementation I5
+ at synthesize Prop5;
+ at end
// RUN: c-index-test -code-completion-at=%s:20:13 %s | FileCheck -check-prefix=CHECK-CC1 %s
// CHECK-CC1: ObjCPropertyDecl:{ResultType int}{TypedText Prop0}
// CHECK-CC1: ObjCPropertyDecl:{ResultType int}{TypedText Prop1}
@@ -80,3 +91,6 @@
// CHECK-CC7-NOT: ObjCIvarDecl:{ResultType id}{TypedText _Prop2}
// CHECK-CC7: ObjCIvarDecl:{ResultType I4 *}{TypedText Prop1} (17)
// CHECK-CC7: ObjCIvarDecl:{ResultType id}{TypedText Prop2_} (7)
+
+// RUN: c-index-test -code-completion-at=%s:57:13 -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-CC8 %s
+// CHECK-CC8: ObjCPropertyDecl:{ResultType int}{TypedText Prop5} (35)
Modified: cfe/branches/tooling/test/Index/get-cursor.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/get-cursor.c?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/get-cursor.c (original)
+++ cfe/branches/tooling/test/Index/get-cursor.c Fri Jun 15 06:08:27 2012
@@ -4,11 +4,17 @@
struct _MyS ww;
+int x, y;
+
// RUN: c-index-test -cursor-at=%s:1:9 \
// RUN: -cursor-at=%s:2:9 \
// RUN: -cursor-at=%s:5:9 \
+// RUN: -cursor-at=%s:7:5 \
+// RUN: -cursor-at=%s:7:8 \
// RUN: %s | FileCheck %s
// CHECK: StructDecl=_MyS:1:8 (Definition)
// CHECK: FieldDecl=foo:2:7 (Definition)
// CHECK: TypeRef=struct _MyS:1:8
+// CHECK: VarDecl=x:7:5
+// CHECK: VarDecl=y:7:8
Modified: cfe/branches/tooling/test/Index/get-cursor.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/get-cursor.m?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/get-cursor.m (original)
+++ cfe/branches/tooling/test/Index/get-cursor.m Fri Jun 15 06:08:27 2012
@@ -69,6 +69,21 @@
@class Forw1, Forw2, Forw3;
+ at interface Test5 {
+ id prop1;
+ id prop2;
+}
+ at property (assign) id prop1;
+ at property (assign) id prop2;
+ at property (assign) id prop3;
+ at property (assign) id prop4;
+ at end
+
+ at implementation Test5
+ at synthesize prop1, prop2;
+ at dynamic prop3, prop4;
+ at end
+
// RUN: c-index-test -cursor-at=%s:4:28 -cursor-at=%s:5:28 %s | FileCheck -check-prefix=CHECK-PROP %s
// CHECK-PROP: ObjCPropertyDecl=foo1:4:26
// CHECK-PROP: ObjCPropertyDecl=foo2:5:27
@@ -102,3 +117,10 @@
// CHECK-SPELLRANGE: 70:8 ObjCClassRef=Forw1:70:8 Extent=[70:8 - 70:13] Spelling=Forw1 ([70:8 - 70:13])
// CHECK-SPELLRANGE: 70:15 ObjCClassRef=Forw2:70:15 Extent=[70:15 - 70:20] Spelling=Forw2 ([70:15 - 70:20])
// CHECK-SPELLRANGE: 70:22 ObjCClassRef=Forw3:70:22 Extent=[70:22 - 70:27] Spelling=Forw3 ([70:22 - 70:27])
+
+// RUN: c-index-test -cursor-at=%s:83:15 -cursor-at=%s:83:21 \
+// RUN: -cursor-at=%s:84:12 -cursor-at=%s:84:20 %s | FileCheck -check-prefix=CHECK-MULTISYNTH %s
+// CHECK-MULTISYNTH: 83:13 ObjCSynthesizeDecl=prop1:76:23 (Definition) Extent=[83:1 - 83:18] Spelling=prop1 ([83:13 - 83:18])
+// CHECK-MULTISYNTH: 83:20 ObjCSynthesizeDecl=prop2:77:23 (Definition) Extent=[83:1 - 83:25] Spelling=prop2 ([83:20 - 83:25])
+// CHECK-MULTISYNTH: 84:10 ObjCDynamicDecl=prop3:78:23 (Definition) Extent=[84:1 - 84:15] Spelling=prop3 ([84:10 - 84:15])
+// CHECK-MULTISYNTH: 84:17 ObjCDynamicDecl=prop4:79:23 (Definition) Extent=[84:1 - 84:22] Spelling=prop4 ([84:17 - 84:22])
Modified: cfe/branches/tooling/test/Index/index-decls.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/index-decls.m?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/index-decls.m (original)
+++ cfe/branches/tooling/test/Index/index-decls.m Fri Jun 15 06:08:27 2012
@@ -11,12 +11,22 @@
@synthesize prop = _prop;
@end
-rdar://11015325
+// rdar://11015325
@interface I1
__attribute__((something)) @interface I2 @end
@end
-// RUN: c-index-test -index-file %s > %t
+ at interface I3
+ at property (assign,readwrite) id auto_prop;
+ at end
+
+ at implementation I3
+-(void)meth {
+ _auto_prop = 0;
+}
+ at end
+
+// RUN: c-index-test -index-file %s -target x86_64-apple-macosx10.7 > %t
// RUN: FileCheck %s -input-file=%t
// CHECK: [indexDeclaration]: kind: objc-class | name: I | {{.*}} | loc: 1:12
// CHECK: [indexDeclaration]: kind: objc-instance-method | name: prop | {{.*}} | loc: 3:2
@@ -28,3 +38,6 @@
// CHECK: [indexDeclaration]: kind: objc-ivar | name: _prop | {{.*}} | loc: 11:20
// CHECK: [indexDeclaration]: kind: objc-instance-method | name: prop | {{.*}} | loc: 11:13 | {{.*}} | lexical-container: [I:10:17]
// CHECK: [indexDeclaration]: kind: objc-instance-method | name: setProp: | {{.*}} | loc: 11:13 | {{.*}} | lexical-container: [I:10:17]
+
+// CHECK: [indexDeclaration]: kind: objc-ivar | name: _auto_prop | {{.*}} | loc: 20:33
+// CHECK: [indexEntityReference]: kind: objc-ivar | name: _auto_prop | {{.*}} | loc: 25:3
Modified: cfe/branches/tooling/test/Index/pch-with-errors.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/pch-with-errors.c?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/pch-with-errors.c (original)
+++ cfe/branches/tooling/test/Index/pch-with-errors.c Fri Jun 15 06:08:27 2012
@@ -38,5 +38,7 @@
// CHECK-INDEX: [indexEntityReference]: kind: function | name: erroneous
// RUN: %clang -fsyntax-only %s -include %t.h 2>&1 | FileCheck -check-prefix=PCH-ERR %s
-
// PCH-ERR: error: PCH file contains compiler errors
+
+// RUN: c-index-test -write-pch %t.pch foobar.c 2>&1 | FileCheck -check-prefix=NONEXISTENT %s
+// NONEXISTENT: Unable to load translation unit
Modified: cfe/branches/tooling/test/Lexer/c90.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Lexer/c90.c?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Lexer/c90.c (original)
+++ cfe/branches/tooling/test/Lexer/c90.c Fri Jun 15 06:08:27 2012
@@ -32,3 +32,10 @@
(void)L"\u1234"; // expected-error {{unicode escape sequences are only valid in C99 or C++}}
(void)L'\u1234'; // expected-error {{unicode escape sequences are only valid in C99 or C++}}
}
+
+#define PREFIX(x) foo ## x
+int test4() {
+ int PREFIX(0p) = 0;
+ int *p = &PREFIX(0p+1);
+ return p[-1];
+}
Modified: cfe/branches/tooling/test/Lexer/char-literal.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Lexer/char-literal.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Lexer/char-literal.cpp (original)
+++ cfe/branches/tooling/test/Lexer/char-literal.cpp Fri Jun 15 06:08:27 2012
@@ -22,3 +22,6 @@
char32_t n = U'ab'; // expected-error {{Unicode character literals may not contain multiple characters}}
char16_t o = '👽'; // expected-error {{character too large for enclosing character literal type}}
+
+char16_t p[2] = u"\U0000FFFF";
+char16_t q[2] = u"\U00010000"; // expected-error {{too long}}
Modified: cfe/branches/tooling/test/Lexer/hexfloat.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Lexer/hexfloat.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Lexer/hexfloat.cpp (original)
+++ cfe/branches/tooling/test/Lexer/hexfloat.cpp Fri Jun 15 06:08:27 2012
@@ -5,3 +5,11 @@
double d = 0x.2p2; // expected-warning{{hexadecimal floating constants are a C99 feature}}
float g = 0x1.2p2; // expected-warning{{hexadecimal floating constants are a C99 feature}}
double h = 0x1.p2; // expected-warning{{hexadecimal floating constants are a C99 feature}}
+
+// PR12717: In order to minimally diverge from the C++ standard, we do not lex
+// 'p[+-]' as part of a pp-number unless the token starts 0x and doesn't contain
+// an underscore.
+double i = 0p+3; // expected-error{{invalid suffix 'p' on integer constant}}
+#define PREFIX(x) foo ## x
+double foo0p = 1, j = PREFIX(0p+3); // ok
+double k = 0x42_amp+3; // expected-error-re{{invalid suffix '_amp' on integer constant|no matching literal operator for call to 'operator "" _amp'}}
Modified: cfe/branches/tooling/test/Misc/emit-html.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Misc/emit-html.c?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Misc/emit-html.c (original)
+++ cfe/branches/tooling/test/Misc/emit-html.c Fri Jun 15 06:08:27 2012
@@ -16,3 +16,11 @@
FOR_ALL_FILES(f) { }
#endif
+// <rdar://problem/11625964>
+// -emit-html filters out # directives, but not _Pragma (or MS __pragma)
+// Diagnostic push/pop is stateful, so re-lexing a file can cause problems
+// if these pragmas are interpreted normally.
+_Pragma("clang diagnostic push")
+_Pragma("clang diagnostic ignored \"-Wformat-extra-args\"")
+_Pragma("clang diagnostic pop")
+
Modified: cfe/branches/tooling/test/Misc/warning-flags.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Misc/warning-flags.c?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Misc/warning-flags.c (original)
+++ cfe/branches/tooling/test/Misc/warning-flags.c Fri Jun 15 06:08:27 2012
@@ -17,7 +17,7 @@
The list of warnings below should NEVER grow. It should gradually shrink to 0.
-CHECK: Warnings without flags (242):
+CHECK: Warnings without flags (241):
CHECK-NEXT: ext_anonymous_struct_union_qualified
CHECK-NEXT: ext_binary_literal
CHECK-NEXT: ext_cast_fn_obj
@@ -26,7 +26,6 @@
CHECK-NEXT: ext_duplicate_declspec
CHECK-NEXT: ext_ellipsis_exception_spec
CHECK-NEXT: ext_empty_fnmacro_arg
-CHECK-NEXT: ext_empty_source_file
CHECK-NEXT: ext_enum_friend
CHECK-NEXT: ext_enum_value_not_int
CHECK-NEXT: ext_enumerator_list_comma
Modified: cfe/branches/tooling/test/PCH/cxx-member-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/PCH/cxx-member-init.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/PCH/cxx-member-init.cpp (original)
+++ cfe/branches/tooling/test/PCH/cxx-member-init.cpp Fri Jun 15 06:08:27 2012
@@ -12,10 +12,14 @@
int &m = n;
S *that = this;
};
+template<typename T> struct X { T t {0}; };
#endif
#ifdef SOURCE
S s;
+
+struct E { explicit E(int); };
+X<E> x;
#elif HEADER
#undef HEADER
#define SOURCE
Modified: cfe/branches/tooling/test/Parser/cxx-using-directive.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/cxx-using-directive.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/cxx-using-directive.cpp (original)
+++ cfe/branches/tooling/test/Parser/cxx-using-directive.cpp Fri Jun 15 06:08:27 2012
@@ -3,7 +3,8 @@
class A {};
namespace B {
- namespace A {} // expected-note{{namespace '::B::A' defined here}}
+ namespace A {} // expected-note{{namespace '::B::A' defined here}} \
+ // expected-note{{namespace 'B::A' defined here}}
using namespace A ;
}
@@ -25,7 +26,7 @@
}
using namespace ! ; // expected-error{{expected namespace name}}
-using namespace A ; // expected-error{{expected namespace name}}
+using namespace A ; // expected-error{{no namespace named 'A'; did you mean 'B::A'?}}
using namespace ::A // expected-error{{expected namespace name}} \
// expected-error{{expected ';' after namespace name}}
B ;
Modified: cfe/branches/tooling/test/Parser/cxx11-type-specifier.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/cxx11-type-specifier.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/cxx11-type-specifier.cpp (original)
+++ cfe/branches/tooling/test/Parser/cxx11-type-specifier.cpp Fri Jun 15 06:08:27 2012
@@ -21,7 +21,4 @@
// And for trailing-type-specifier-seq
-// FIXME: Don't treat an ill-formed trailing-return-type the same as no
-// trailing-return-type, and avoid the second diagnostic.
-auto f() -> unknown; // expected-error{{unknown type name 'unknown'}} \
- expected-error{{'auto' return without trailing return type}}
+auto f() -> unknown; // expected-error{{unknown type name 'unknown'}}
Modified: cfe/branches/tooling/test/Parser/ms-inline-asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/ms-inline-asm.c?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/ms-inline-asm.c (original)
+++ cfe/branches/tooling/test/Parser/ms-inline-asm.c Fri Jun 15 06:08:27 2012
@@ -20,6 +20,19 @@
__asm int 4
return 10;
}
-int t7() { // expected-note {{to match this}}
+int t7() {
+ __asm {
+ push ebx
+ mov ebx, 0x07
+ pop ebx
+ }
+}
+void t8() {
+ __asm nop __asm nop __asm nop
+}
+void t9() {
+ __asm nop __asm nop ; __asm nop
+}
+int t_fail() { // expected-note {{to match this}}
__asm
__asm { // expected-error 3 {{expected}} expected-note {{to match this}}
Modified: cfe/branches/tooling/test/Parser/opencl-pragma.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/opencl-pragma.cl?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/opencl-pragma.cl (original)
+++ cfe/branches/tooling/test/Parser/opencl-pragma.cl Fri Jun 15 06:08:27 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -verify -pedantic -Wno-empty-translation-unit -fsyntax-only
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
Modified: cfe/branches/tooling/test/Preprocessor/comment_save.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Preprocessor/comment_save.c?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Preprocessor/comment_save.c (original)
+++ cfe/branches/tooling/test/Preprocessor/comment_save.c Fri Jun 15 06:08:27 2012
@@ -6,3 +6,7 @@
/* bar */
// CHECK: /* bar */
+#if FOO
+#endif
+/* baz */
+// CHECK: /* baz */
Modified: cfe/branches/tooling/test/Preprocessor/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Preprocessor/init.c?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Preprocessor/init.c (original)
+++ cfe/branches/tooling/test/Preprocessor/init.c Fri Jun 15 06:08:27 2012
@@ -967,10 +967,11 @@
// MSP430:#define __WINT_WIDTH__ 16
// MSP430:#define __clang__ 1
//
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -fno-signed-char < /dev/null | FileCheck -check-prefix PPC64 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu pwr7 -fno-signed-char < /dev/null | FileCheck -check-prefix PPC64 %s
//
// PPC64:#define _ARCH_PPC 1
// PPC64:#define _ARCH_PPC64 1
+// PPC64:#define _ARCH_PWR7 1
// PPC64:#define _BIG_ENDIAN 1
// PPC64:#define _LP64 1
// PPC64:#define __BIG_ENDIAN__ 1
Modified: cfe/branches/tooling/test/Preprocessor/macro_paste_c_block_comment.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Preprocessor/macro_paste_c_block_comment.c?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Preprocessor/macro_paste_c_block_comment.c (original)
+++ cfe/branches/tooling/test/Preprocessor/macro_paste_c_block_comment.c Fri Jun 15 06:08:27 2012
@@ -3,3 +3,6 @@
#define COMM / ## *
COMM // expected-error {{pasting formed '/*', an invalid preprocessing token}}
+// Demonstrate that an invalid preprocessing token
+// doesn't swallow the rest of the file...
+#error EOF // expected-error {{EOF}}
Modified: cfe/branches/tooling/test/Preprocessor/predefined-arch-macros.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Preprocessor/predefined-arch-macros.c?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/branches/tooling/test/Preprocessor/predefined-arch-macros.c Fri Jun 15 06:08:27 2012
@@ -1025,7 +1025,9 @@
// CHECK_BDVER1_M64: #define __AVX__ 1
// CHECK_BDVER1_M64-NOT: #define __3dNOW_A__ 1
// CHECK_BDVER1_M64-NOT: #define __3dNOW__ 1
+// CHECK_BDVER1_M64: #define __FMA4__ 1
// CHECK_BDVER1_M64: #define __MMX__ 1
+// CHECK_BDVER1_M64: #define __PCLMUL__ 1
// CHECK_BDVER1_M64: #define __SSE2_MATH__ 1
// CHECK_BDVER1_M64: #define __SSE2__ 1
// CHECK_BDVER1_M64: #define __SSE3__ 1
@@ -1035,6 +1037,7 @@
// CHECK_BDVER1_M64: #define __SSE_MATH__ 1
// CHECK_BDVER1_M64: #define __SSE__ 1
// CHECK_BDVER1_M64: #define __SSSE3__ 1
+// CHECK_BDVER1_M64: #define __XOP__ 1
// CHECK_BDVER1_M64: #define __amd64 1
// CHECK_BDVER1_M64: #define __amd64__ 1
// CHECK_BDVER1_M64: #define __bdver1 1
Modified: cfe/branches/tooling/test/Preprocessor/undef-error.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Preprocessor/undef-error.c?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Preprocessor/undef-error.c (original)
+++ cfe/branches/tooling/test/Preprocessor/undef-error.c Fri Jun 15 06:08:27 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -pedantic-errors -verify
+// RUN: %clang_cc1 %s -pedantic-errors -Wno-empty-translation-unit -verify
// PR2045
#define b
Modified: cfe/branches/tooling/test/Sema/c89-2.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/c89-2.c?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/c89-2.c (original)
+++ cfe/branches/tooling/test/Sema/c89-2.c Fri Jun 15 06:08:27 2012
@@ -1,4 +1,4 @@
-/* RUN: %clang_cc1 %s -std=c89 -pedantic-errors -verify
+/* RUN: %clang_cc1 %s -std=c89 -pedantic-errors -Wno-empty-translation-unit -verify
*/
#if 1LL /* expected-error {{long long}} */
Modified: cfe/branches/tooling/test/SemaCXX/constructor-initializer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/constructor-initializer.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/constructor-initializer.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/constructor-initializer.cpp Fri Jun 15 06:08:27 2012
@@ -126,21 +126,24 @@
// A silly class used to demonstrate field-is-uninitialized in constructors with
// multiple params.
+int IntParam(int i) { return 0; };
class TwoInOne { public: TwoInOne(TwoInOne a, TwoInOne b) {} };
class InitializeUsingSelfTest {
bool A;
char* B;
int C;
TwoInOne D;
- InitializeUsingSelfTest(int E)
+ int E;
+ InitializeUsingSelfTest(int F)
: A(A), // expected-warning {{field is uninitialized when used here}}
B((((B)))), // expected-warning {{field is uninitialized when used here}}
C(A && InitializeUsingSelfTest::C), // expected-warning {{field is uninitialized when used here}}
D(D, // expected-warning {{field is uninitialized when used here}}
- D) {} // expected-warning {{field is uninitialized when used here}}
+ D), // expected-warning {{field is uninitialized when used here}}
+ E(IntParam(E)) {} // expected-warning {{field is uninitialized when used here}}
};
-int IntWrapper(int i) { return 0; };
+int IntWrapper(int &i) { return 0; };
class InitializeUsingSelfExceptions {
int A;
int B;
Modified: cfe/branches/tooling/test/SemaCXX/cxx0x-defaulted-functions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/cxx0x-defaulted-functions.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/cxx0x-defaulted-functions.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/cxx0x-defaulted-functions.cpp Fri Jun 15 06:08:27 2012
@@ -51,3 +51,9 @@
struct lit { constexpr lit() {} };
S<lit> s_lit; // ok
S<bar> s_bar; // ok
+
+struct Friends {
+ friend S<bar>::S();
+ friend S<bar>::S(const S&);
+ friend S<bar>::S(S&&);
+};
Modified: cfe/branches/tooling/test/SemaCXX/deleted-operator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/deleted-operator.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/deleted-operator.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/deleted-operator.cpp Fri Jun 15 06:08:27 2012
@@ -8,8 +8,8 @@
int PR10757f() {
PR10757 a1;
// FIXME: We get a ridiculous number of "built-in candidate" notes here...
- if(~a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 6 {{built-in candidate}}
- if(a1==a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 81 {{built-in candidate}}
+ if(~a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 8 {{built-in candidate}}
+ if(a1==a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 121 {{built-in candidate}}
}
struct DelOpDel {
Modified: cfe/branches/tooling/test/SemaCXX/elaborated-type-specifier.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/elaborated-type-specifier.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/elaborated-type-specifier.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/elaborated-type-specifier.cpp Fri Jun 15 06:08:27 2012
@@ -19,7 +19,7 @@
namespace NS {
class X {
public:
- void test_elab2(struct S4 *s4);
+ void test_elab2(struct S4 *s4); // expected-note{{'NS::S4' declared here}}
};
void X::test_elab2(S4 *s4) { } // expected-note{{passing argument to parameter 's4' here}}
@@ -35,8 +35,7 @@
}
void test_S5_scope() {
- S4 *s4; // expected-error{{use of undeclared identifier 'S4'}} \
- // expected-error{{use of undeclared identifier 's4'}}
+ S4 *s4; // expected-error{{unknown type name 'S4'; did you mean 'NS::S4'?}}
}
int test_funcparam_scope(struct S5 * s5) {
@@ -44,5 +43,3 @@
if (s5 == s5_2) return 1; // expected-error {{comparison of distinct pointer types ('struct S5 *' and 'struct S5 *')}}
return 0;
}
-
-
Modified: cfe/branches/tooling/test/SemaCXX/format-strings-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/format-strings-0x.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/format-strings-0x.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/format-strings-0x.cpp Fri Jun 15 06:08:27 2012
@@ -12,4 +12,16 @@
scanf("%afoobar", fp);
printf(nullptr);
printf(*sp); // expected-warning {{not a string literal}}
+
+ // PR13099
+ printf(
+ R"foobar(%)foobar"
+ R"bazquux(d)bazquux" // expected-warning {{more '%' conversions than data arguments}}
+ R"xyzzy()xyzzy");
+
+ printf(u8"this is %d test", 0); // ok
+ printf(u8R"foo(
+ \u1234\U0010fffe
+ %d)foo" // expected-warning {{more '%' conversions than data arguments}}
+ );
}
Modified: cfe/branches/tooling/test/SemaCXX/function-redecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/function-redecl.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/function-redecl.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/function-redecl.cpp Fri Jun 15 06:08:27 2012
@@ -76,12 +76,9 @@
void GetCart(int count) const;
};
// This out-of-line definition was fine...
-void Crash::cart(int count) const {} // expected-error {{out-of-line definition of 'cart' does not match any declaration in 'Crash'}} \
- // expected-note {{'cart' declared here}} \
- // expected-note {{previous definition is here}}
+void Crash::cart(int count) const {} // expected-error {{out-of-line definition of 'cart' does not match any declaration in 'Crash'}}
// ...while this one crashed clang
-void Crash::chart(int count) const {} // expected-error {{out-of-line definition of 'chart' does not match any declaration in 'Crash'; did you mean 'cart'?}} \
- // expected-error {{redefinition of 'cart'}}
+void Crash::chart(int count) const {} // expected-error {{out-of-line definition of 'chart' does not match any declaration in 'Crash'}}
class TestConst {
public:
@@ -98,3 +95,24 @@
struct J { int typo() const; };
int J::typo_() { return 3; } // expected-error {{out-of-line definition of 'typo_' does not match any declaration in 'J'}}
+
+// Ensure we correct the redecl of Foo::isGood to Bar::Foo::isGood and not
+// Foo::IsGood even though Foo::IsGood is technically a closer match since it
+// already has a body. Also make sure Foo::beEvil is corrected to Foo::BeEvil
+// since it is a closer match than Bar::Foo::beEvil and neither have a body.
+namespace redecl_typo {
+namespace Foo {
+ bool IsGood() { return false; }
+ void BeEvil(); // expected-note {{'BeEvil' declared here}}
+}
+namespace Bar {
+ namespace Foo {
+ bool isGood(); // expected-note {{'Bar::Foo::isGood' declared here}}
+ void beEvil();
+ }
+}
+bool Foo::isGood() { // expected-error {{out-of-line definition of 'isGood' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'Bar::Foo::isGood'?}}
+ return true;
+}
+void Foo::beEvil() {} // expected-error {{out-of-line definition of 'beEvil' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'BeEvil'?}}
+}
Modified: cfe/branches/tooling/test/SemaCXX/nested-name-spec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/nested-name-spec.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/nested-name-spec.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/nested-name-spec.cpp Fri Jun 15 06:08:27 2012
@@ -143,7 +143,7 @@
void g(int&); // expected-note{{type of 1st parameter of member declaration does not match definition ('int &' vs 'const int &')}}
}
-void A::f() {} // expected-error{{out-of-line definition of 'f' does not match any declaration in namespace 'A'}}
+void A::f() {} // expected-error-re{{out-of-line definition of 'f' does not match any declaration in namespace 'A'$}}
void A::g(const int&) { } // expected-error{{out-of-line definition of 'g' does not match any declaration in namespace 'A'}}
@@ -286,3 +286,15 @@
template <typename T>
struct A2<T>::B::C; // expected-error {{no struct named 'C'}}
}
+
+namespace PR13033 {
+namespace NS {
+ int a; // expected-note {{'NS::a' declared here}}
+ int longer_b; //expected-note {{'NS::longer_b' declared here}}
+}
+
+// Suggest adding a namespace qualifier to both variable names even though one
+// is only a single character long.
+int foobar = a + longer_b; // expected-error {{use of undeclared identifier 'a'; did you mean 'NS::a'?}} \
+ // expected-error {{use of undeclared identifier 'longer_b'; did you mean 'NS::longer_b'?}}
+}
Modified: cfe/branches/tooling/test/SemaCXX/overloaded-builtin-operators.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/overloaded-builtin-operators.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/overloaded-builtin-operators.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/overloaded-builtin-operators.cpp Fri Jun 15 06:08:27 2012
@@ -174,7 +174,7 @@
// FIXME: lots of candidates here!
(void)(1.0f * a); // expected-error{{ambiguous}} \
// expected-note 4{{candidate}} \
- // expected-note {{remaining 77 candidates omitted; pass -fshow-overloads=all to show them}}
+ // expected-note {{remaining 117 candidates omitted; pass -fshow-overloads=all to show them}}
}
// pr5432
@@ -256,3 +256,15 @@
ri--;
}
}
+
+namespace PR12964 {
+ struct X { operator __int128() const; } x;
+ bool a = x == __int128(0);
+ bool b = x == 0;
+
+ struct Y { operator unsigned __int128() const; } y;
+ bool c = y == __int128(0);
+ bool d = y == 0;
+
+ bool e = x == y;
+}
Modified: cfe/branches/tooling/test/SemaCXX/qualified-id-lookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/qualified-id-lookup.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/qualified-id-lookup.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/qualified-id-lookup.cpp Fri Jun 15 06:08:27 2012
@@ -86,14 +86,15 @@
namespace a {
namespace a { // A1
namespace a { // A2
- int i;
+ int i; // expected-note{{'::a::a::a::i' declared here}}
}
}
}
void test_a() {
- a::a::i = 3; // expected-error{{no member named 'i'}}
+ a::a::i = 3; // expected-error{{no member named 'i' in namespace 'a::a'; did you mean '::a::a::a::i'?}}
a::a::a::i = 4;
+ a::a::j = 3; // expected-error-re{{no member named 'j' in namespace 'a::a'$}}
}
struct Undef { // expected-note{{definition of 'Undef' is not complete until the closing '}'}}
Modified: cfe/branches/tooling/test/SemaCXX/typo-correction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/typo-correction.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/typo-correction.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/typo-correction.cpp Fri Jun 15 06:08:27 2012
@@ -206,3 +206,16 @@
namespace bazquux { struct Thing {}; }
void f() { Thing t; } // expected-error{{unknown type name 'Thing'}}
}
+
+namespace PR13051 {
+ template<typename T> struct S {
+ template<typename U> void f();
+ operator bool() const;
+ };
+
+ void f() {
+ f(&S<int>::tempalte f<int>); // expected-error{{did you mean 'template'?}}
+ f(&S<int>::opeartor bool); // expected-error{{did you mean 'operator'?}}
+ f(&S<int>::foo); // expected-error-re{{no member named 'foo' in 'PR13051::S<int>'$}}
+ }
+}
Modified: cfe/branches/tooling/test/SemaCXX/uninitialized.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/uninitialized.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/uninitialized.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/uninitialized.cpp Fri Jun 15 06:08:27 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -std=c++11 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -Wno-unused-value -std=c++11 -verify %s
int foo(int x);
int bar(int* x);
@@ -152,9 +152,9 @@
S(bool (*)[1]) : x(x) {} // expected-warning {{field is uninitialized when used here}}
S(bool (*)[2]) : x(x + 1) {} // expected-warning {{field is uninitialized when used here}}
- S(bool (*)[3]) : x(x + x) {} // expected-warning {{field is uninitialized when used here}}
+ S(bool (*)[3]) : x(x + x) {} // expected-warning 2{{field is uninitialized when used here}}
S(bool (*)[4]) : x(static_cast<long>(x) + 1) {} // expected-warning {{field is uninitialized when used here}}
- S(bool (*)[5]) : x(foo(x)) {} // FIXME: This should warn!
+ S(bool (*)[5]) : x(foo(x)) {} // expected-warning {{field is uninitialized when used here}}
// These don't actually require the value of x and so shouldn't warn.
S(char (*)[1]) : x(sizeof(x)) {} // rdar://8610363
@@ -213,3 +213,83 @@
auto f1 = [] (int x, int y) { int z; return x + y + z; }; // expected-warning{{variable 'z' is uninitialized when used here}} expected-note {{initialize the variable 'z' to silence this warning}}
return f1(1, 2);
}
+
+namespace {
+ struct A {
+ enum { A1 };
+ static int A2() {return 5;}
+ int A3;
+ int A4() { return 5;}
+ };
+
+ struct B {
+ A a;
+ };
+
+ struct C {
+ C() {}
+ C(int x) {}
+ static A a;
+ B b;
+ };
+ A C::a = A();
+
+ // Accessing non-static members will give a warning.
+ struct D {
+ C c;
+ D(char (*)[1]) : c(c.b.a.A1) {}
+ D(char (*)[2]) : c(c.b.a.A2()) {}
+ D(char (*)[3]) : c(c.b.a.A3) {} // expected-warning {{field is uninitialized when used here}}
+ D(char (*)[4]) : c(c.b.a.A4()) {} // expected-warning {{field is uninitialized when used here}}
+
+ // c::a is static, so it is already initialized
+ D(char (*)[5]) : c(c.a.A1) {}
+ D(char (*)[6]) : c(c.a.A2()) {}
+ D(char (*)[7]) : c(c.a.A3) {}
+ D(char (*)[8]) : c(c.a.A4()) {}
+ };
+
+ struct E {
+ int a, b, c;
+ E(char (*)[1]) : a(a ? b : c) {} // expected-warning {{field is uninitialized when used here}}
+ E(char (*)[2]) : a(b ? a : a) {} // expected-warning 2{{field is uninitialized when used here}}
+ E(char (*)[3]) : a(b ? (a) : c) {} // expected-warning {{field is uninitialized when used here}}
+ E(char (*)[4]) : a(b ? c : (a+c)) {} // expected-warning {{field is uninitialized when used here}}
+ E(char (*)[5]) : a(b ? c : b) {}
+
+ E(char (*)[6]) : a(a ?: a) {} // expected-warning 2{{field is uninitialized when used here}}
+ E(char (*)[7]) : a(b ?: a) {} // expected-warning {{field is uninitialized when used here}}
+ E(char (*)[8]) : a(a ?: c) {} // expected-warning {{field is uninitialized when used here}}
+ E(char (*)[9]) : a(b ?: c) {}
+
+ E(char (*)[10]) : a((a, a, b)) {}
+ E(char (*)[11]) : a((c + a, a + 1, b)) {} // expected-warning 2{{field is uninitialized when used here}}
+ E(char (*)[12]) : a((b + c, c, a)) {} // expected-warning {{field is uninitialized when used here}}
+ E(char (*)[13]) : a((a, a, a, a)) {} // expected-warning {{field is uninitialized when used here}}
+ E(char (*)[14]) : a((b, c, c)) {}
+ };
+
+ struct F {
+ int a;
+ F* f;
+ F(int) {}
+ F() {}
+ };
+
+ int F::*ptr = &F::a;
+ F* F::*f_ptr = &F::f;
+ struct G {
+ F f1, f2;
+ F *f3, *f4;
+ G(char (*)[1]) : f1(f1) {} // expected-warning {{field is uninitialized when used here}}
+ G(char (*)[2]) : f2(f1) {}
+ G(char (*)[3]) : f2(F()) {}
+
+ G(char (*)[4]) : f1(f1.*ptr) {} // expected-warning {{field is uninitialized when used here}}
+ G(char (*)[5]) : f2(f1.*ptr) {}
+
+ G(char (*)[6]) : f3(f3) {} // expected-warning {{field is uninitialized when used here}}
+ G(char (*)[7]) : f3(f3->*f_ptr) {} // expected-warning {{field is uninitialized when used here}}
+ G(char (*)[8]) : f3(new F(f3->*ptr)) {} // expected-warning {{field is uninitialized when used here}}
+ };
+}
Propchange: cfe/branches/tooling/test/SemaCXX/warn-unreachable.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jun 15 06:08:27 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-158060
+/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,146581-158512
Modified: cfe/branches/tooling/test/SemaCXX/warn-unused-member.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/warn-unused-member.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/warn-unused-member.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/warn-unused-member.cpp Fri Jun 15 06:08:27 2012
@@ -115,6 +115,8 @@
Trivial user_constructor_;
NonTrivialConstructor non_trivial_constructor_;
NonTrivialDestructor non_trivial_destructor_;
+
+ int attr_ __attribute__((unused));
};
class EverythingUsed {
@@ -140,6 +142,13 @@
int by_initializer_;
};
+namespace templates {
+class B {
+ template <typename T> void f(T t);
+ int a;
+};
+} // namespace templates
+
namespace mutual_friends {
// Undefined methods make mutual friends undefined.
class A {
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=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc-bridged-cast.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc-bridged-cast.m Fri Jun 15 06:08:27 2012
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
typedef const void *CFTypeRef;
CFTypeRef CFBridgingRetain(id X);
@@ -32,13 +33,35 @@
// rdar://problem/9629566 - temporary workaround
CFTypeRef cf5 = (__bridge_retain CFTypeRef)CreateSomething(); // expected-error {{unknown cast annotation __bridge_retain; did you mean __bridge_retained?}}
+ // CHECK: fix-it:"{{.*}}":{35:20-35:35}:"__bridge_retained"
}
-void fixits() {
+CFTypeRef 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 CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
+ // CHECK: fix-it:"{{.*}}":{40:14-40:14}:"__bridge "
+ // CHECK: fix-it:"{{.*}}":{40:17-40:17}:"CFBridgingRelease("
+ // CHECK: fix-it:"{{.*}}":{40:36-40:36}:")"
+
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 CFBridgingRetain call to make an ARC object available as a +1 'CFTypeRef' (aka 'const void *')}}
+ // CHECK: fix-it:"{{.*}}":{47:20-47:20}:"__bridge "
+ // CHECK: fix-it:"{{.*}}":{47:30-47:30}:"CFBridgingRetain("
+ // CHECK: fix-it:"{{.*}}":{47:47-47:47}:")"
+
+ return (obj1); // expected-error{{implicit conversion 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 CFBridgingRetain call to make an ARC object available as a +1 'CFTypeRef' (aka 'const void *')}}
+ // CHECK: fix-it:"{{.*}}":{54:10-54:10}:"(__bridge CFTypeRef)"
+ // CHECK: fix-it:"{{.*}}":{54:10-54:10}:"CFBridgingRetain"
+}
+
+CFTypeRef fixitsWithSpace(id obj) {
+ return(obj); // expected-error{{implicit conversion 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 CFBridgingRetain call to make an ARC object available as a +1 'CFTypeRef' (aka 'const void *')}}
+ // CHECK: fix-it:"{{.*}}":{62:9-62:9}:"(__bridge CFTypeRef)"
+ // CHECK: fix-it:"{{.*}}":{62:9-62:9}:" CFBridgingRetain"
}
Modified: cfe/branches/tooling/test/SemaObjC/cocoa-api-usage.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/cocoa-api-usage.m?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/cocoa-api-usage.m (original)
+++ cfe/branches/tooling/test/SemaObjC/cocoa-api-usage.m Fri Jun 15 06:08:27 2012
@@ -1,9 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -fsyntax-only -Wobjc-cocoa-api -verify
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc %s -fsyntax-only -Wobjc-cocoa-api -verify
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c %s.fixed -fsyntax-only
-// RUN: cp %s %t.m
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %t.m -fixit -Wobjc-cocoa-api
-// RUN: diff %s.fixed %t.m
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc -x objective-c %s.fixed -fsyntax-only
// RUN: cp %s %t.m
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc %t.m -fixit -Wobjc-cocoa-api
// RUN: diff %s.fixed %t.m
@@ -82,7 +78,7 @@
void foo() {
NSString *str = M([NSString stringWithString:@"foo"]); // expected-warning {{redundant}}
- str = [[NSString alloc] initWithString:@"foo"];
+ str = [[NSString alloc] initWithString:@"foo"]; // expected-warning {{redundant}}
NSArray *arr = [NSArray arrayWithArray:@[str]]; // expected-warning {{redundant}}
NSDictionary *dict = [NSDictionary dictionaryWithDictionary:@{str: arr}]; // expected-warning {{redundant}}
}
Modified: cfe/branches/tooling/test/SemaObjC/cocoa-api-usage.m.fixed
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/cocoa-api-usage.m.fixed?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/cocoa-api-usage.m.fixed (original)
+++ cfe/branches/tooling/test/SemaObjC/cocoa-api-usage.m.fixed Fri Jun 15 06:08:27 2012
@@ -1,9 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -fsyntax-only -Wobjc-cocoa-api -verify
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc %s -fsyntax-only -Wobjc-cocoa-api -verify
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c %s.fixed -fsyntax-only
-// RUN: cp %s %t.m
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %t.m -fixit -Wobjc-cocoa-api
-// RUN: diff %s.fixed %t.m
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc -x objective-c %s.fixed -fsyntax-only
// RUN: cp %s %t.m
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc %t.m -fixit -Wobjc-cocoa-api
// RUN: diff %s.fixed %t.m
@@ -82,7 +78,7 @@
void foo() {
NSString *str = M(@"foo"); // expected-warning {{redundant}}
- str = [[NSString alloc] initWithString:@"foo"];
+ str = @"foo"; // expected-warning {{redundant}}
NSArray *arr = @[str]; // expected-warning {{redundant}}
NSDictionary *dict = @{str: arr}; // expected-warning {{redundant}}
}
Modified: cfe/branches/tooling/test/SemaObjCXX/arc-0x.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjCXX/arc-0x.mm?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjCXX/arc-0x.mm (original)
+++ cfe/branches/tooling/test/SemaObjCXX/arc-0x.mm Fri Jun 15 06:08:27 2012
@@ -22,7 +22,7 @@
__strong id *idp = new auto(obj);
__strong id array[17];
- for (auto x : array) {
+ for (auto x : array) { // expected-warning{{'auto' deduced as 'id' in declaration of 'x'}}
__strong id *xPtr = &x;
}
@@ -51,3 +51,24 @@
(void) ^{ (void) p; };
(void) ^{ (void) v; }; // expected-error {{cannot capture __autoreleasing variable in a block}}
}
+
+
+// <rdar://problem/11319689>
+// warn when initializing an 'auto' variable with an 'id' initializer expression
+
+void testAutoId(id obj) {
+ auto x = obj; // expected-warning{{'auto' deduced as 'id' in declaration of 'x'}}
+}
+
+// ...but don't warn if it's coming from a template parameter.
+template<typename T>
+void autoTemplateFunction(T param, id obj) {
+ auto x = param; // no-warning
+ auto y = obj; // expected-warning{{'auto' deduced as 'id' in declaration of 'y'}}
+}
+
+void testAutoIdTemplate(id obj) {
+ autoTemplateFunction(obj, obj); // no-warning
+}
+
+
Modified: cfe/branches/tooling/test/SemaTemplate/instantiate-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaTemplate/instantiate-init.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaTemplate/instantiate-init.cpp (original)
+++ cfe/branches/tooling/test/SemaTemplate/instantiate-init.cpp Fri Jun 15 06:08:27 2012
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
-struct X0 { // expected-note 4{{candidate}}
+struct X0 { // expected-note 8{{candidate}}
X0(int*, float*); // expected-note 4{{candidate}}
};
@@ -107,3 +107,14 @@
array_lengthof(Description<float*>::data); // expected-error{{no matching function for call to 'array_lengthof'}}
}
}
+
+namespace PR13064 {
+ // Ensure that in-class direct-initialization is instantiated as
+ // direct-initialization and likewise copy-initialization is instantiated as
+ // copy-initialization.
+ struct A { explicit A(int); }; // expected-note{{here}}
+ template<typename T> struct B { T a { 0 }; };
+ B<A> b;
+ template<typename T> struct C { T a = { 0 }; }; // expected-error{{explicit}}
+ C<A> c; // expected-note{{here}}
+}
Modified: cfe/branches/tooling/test/SemaTemplate/typename-specifier.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaTemplate/typename-specifier.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaTemplate/typename-specifier.cpp (original)
+++ cfe/branches/tooling/test/SemaTemplate/typename-specifier.cpp Fri Jun 15 06:08:27 2012
@@ -118,7 +118,7 @@
namespace missing_typename {
-template <class T1, class T2> struct pair {}; // expected-note 5 {{template parameter is declared here}}
+template <class T1, class T2> struct pair {}; // expected-note 7 {{template parameter is declared here}}
template <class T1, class T2>
struct map {
@@ -132,10 +132,13 @@
struct ExampleItemSet {
typedef ExampleItem* iterator;
+ ExampleItem* operator[](unsigned);
};
void foo() {
pair<ExampleItemSet::iterator, int> i; // expected-error {{template argument for template type parameter must be a type; did you forget 'typename'?}}
+ pair<this->ExampleItemSet::iterator, int> i; // expected-error-re {{template argument for template type parameter must be a type$}}
+ pair<ExampleItemSet::operator[], int> i; // expected-error-re {{template argument for template type parameter must be a type$}}
}
pair<ExampleItemSet::iterator, int> elt; // expected-error {{template argument for template type parameter must be a type; did you forget 'typename'?}}
Propchange: cfe/branches/tooling/test/Tooling/clang-check-pwd.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo (removed)
@@ -1,2 +0,0 @@
-/cfe/branches/type-system-rewrite/test/Tooling/clang-check-pwd.cpp:134693-134817
-/cfe/trunk/test/SemaTemplate/test/Tooling/clang-check-pwd.cpp:126920
Propchange: cfe/branches/tooling/test/Tooling/clang-check.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo (removed)
@@ -1,2 +0,0 @@
-/cfe/branches/type-system-rewrite/test/Tooling/clang-check.cpp:134693-134817
-/cfe/trunk/test/SemaTemplate/test/Tooling/clang-check.cpp:126920
Propchange: cfe/branches/tooling/tools/clang-check/ClangCheck.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo (removed)
@@ -1,2 +0,0 @@
-/cfe/branches/type-system-rewrite/tools/clang-check/ClangCheck.cpp:134693-134817
-/cfe/trunk/test/SemaTemplate/tools/clang-check/ClangCheck.cpp:126920
Propchange: cfe/branches/tooling/tools/clang-check/Makefile
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo (removed)
@@ -1,2 +0,0 @@
-/cfe/branches/type-system-rewrite/tools/clang-check/Makefile:134693-134817
-/cfe/trunk/test/SemaTemplate/tools/clang-check/Makefile:126920
Modified: cfe/branches/tooling/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/CIndex.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/CIndex.cpp (original)
+++ cfe/branches/tooling/tools/libclang/CIndex.cpp Fri Jun 15 06:08:27 2012
@@ -1068,7 +1068,8 @@
bool CursorVisitor::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *PD) {
if (ObjCIvarDecl *Ivar = PD->getPropertyIvarDecl())
- return Visit(MakeCursorMemberRef(Ivar, PD->getPropertyIvarDeclLoc(), TU));
+ if (PD->isIvarNameSpecified())
+ return Visit(MakeCursorMemberRef(Ivar, PD->getPropertyIvarDeclLoc(), TU));
return false;
}
@@ -2692,6 +2693,8 @@
ASTUnit *CXXUnit = static_cast<ASTUnit *>(TU->TUData);
ASTUnit::ConcurrencyCheck Check(*CXXUnit);
+ if (!CXXUnit->hasSema())
+ return CXSaveError_InvalidTU;
SaveTranslationUnitInfo STUI = { TU, FileName, options, CXSaveError_None };
@@ -3503,6 +3506,8 @@
return createCXString("ReturnStmt");
case CXCursor_AsmStmt:
return createCXString("AsmStmt");
+ case CXCursor_MSAsmStmt:
+ return createCXString("MSAsmStmt");
case CXCursor_ObjCAtTryStmt:
return createCXString("ObjCAtTryStmt");
case CXCursor_ObjCAtCatchStmt:
@@ -3611,12 +3616,15 @@
struct GetCursorData {
SourceLocation TokenBeginLoc;
bool PointsAtMacroArgExpansion;
+ bool VisitedObjCPropertyImplDecl;
+ SourceLocation VisitedDeclaratorDeclStartLoc;
CXCursor &BestCursor;
GetCursorData(SourceManager &SM,
SourceLocation tokenBegin, CXCursor &outputCursor)
: TokenBeginLoc(tokenBegin), BestCursor(outputCursor) {
PointsAtMacroArgExpansion = SM.isMacroArgExpansion(tokenBegin);
+ VisitedObjCPropertyImplDecl = false;
}
};
@@ -3656,6 +3664,32 @@
!ID->isThisDeclarationADefinition())
return CXChildVisit_Break;
}
+
+ } else if (DeclaratorDecl *DD
+ = dyn_cast_or_null<DeclaratorDecl>(getCursorDecl(cursor))) {
+ SourceLocation StartLoc = DD->getSourceRange().getBegin();
+ // Check that when we have multiple declarators in the same line,
+ // that later ones do not override the previous ones.
+ // If we have:
+ // int Foo, Bar;
+ // source ranges for both start at 'int', so 'Bar' will end up overriding
+ // 'Foo' even though the cursor location was at 'Foo'.
+ if (Data->VisitedDeclaratorDeclStartLoc == StartLoc)
+ return CXChildVisit_Break;
+ Data->VisitedDeclaratorDeclStartLoc = StartLoc;
+
+ } else if (ObjCPropertyImplDecl *PropImp
+ = dyn_cast_or_null<ObjCPropertyImplDecl>(getCursorDecl(cursor))) {
+ (void)PropImp;
+ // Check that when we have multiple @synthesize in the same line,
+ // that later ones do not override the previous ones.
+ // If we have:
+ // @synthesize Foo, Bar;
+ // source ranges for both start at '@', so 'Bar' will end up overriding
+ // 'Foo' even though the cursor location was at 'Foo'.
+ if (Data->VisitedObjCPropertyImplDecl)
+ return CXChildVisit_Break;
+ Data->VisitedObjCPropertyImplDecl = true;
}
}
Modified: cfe/branches/tooling/tools/libclang/CIndexUSRs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/CIndexUSRs.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/CIndexUSRs.cpp (original)
+++ cfe/branches/tooling/tools/libclang/CIndexUSRs.cpp Fri Jun 15 06:08:27 2012
@@ -754,7 +754,7 @@
case TemplateArgument::Integral:
Out << 'V';
VisitType(Arg.getIntegralType());
- Out << *Arg.getAsIntegral();
+ Out << Arg.getAsIntegral();
break;
}
}
Modified: cfe/branches/tooling/tools/libclang/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/CMakeLists.txt?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/CMakeLists.txt (original)
+++ cfe/branches/tooling/tools/libclang/CMakeLists.txt Fri Jun 15 06:08:27 2012
@@ -76,13 +76,6 @@
INSTALL_NAME_DIR "@executable_path/../lib")
endif()
- if(MSVC)
- # windows.h doesn't compile with /Za
- get_target_property(NON_ANSI_COMPILE_FLAGS libclang COMPILE_FLAGS)
- string(REPLACE "/Za" "" NON_ANSI_COMPILE_FLAGS ${NON_ANSI_COMPILE_FLAGS})
- set_target_properties(libclang PROPERTIES
- COMPILE_FLAGS ${NON_ANSI_COMPILE_FLAGS})
- endif()
set(LIBCLANG_STATIC_TARGET_NAME libclang_static)
else()
Modified: cfe/branches/tooling/tools/libclang/CXCursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/CXCursor.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/CXCursor.cpp (original)
+++ cfe/branches/tooling/tools/libclang/CXCursor.cpp Fri Jun 15 06:08:27 2012
@@ -148,6 +148,10 @@
case Stmt::AsmStmtClass:
K = CXCursor_AsmStmt;
break;
+
+ case Stmt::MSAsmStmtClass:
+ K = CXCursor_MSAsmStmt;
+ break;
case Stmt::ObjCAtTryStmtClass:
K = CXCursor_ObjCAtTryStmt;
Modified: cfe/branches/tooling/tools/libclang/IndexDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/IndexDecl.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/IndexDecl.cpp (original)
+++ cfe/branches/tooling/tools/libclang/IndexDecl.cpp Fri Jun 15 06:08:27 2012
@@ -154,7 +154,20 @@
IndexCtx.handleObjCImplementation(D);
IndexCtx.indexTUDeclsInObjCContainer();
- IndexCtx.indexDeclContext(D);
+
+ // Index the ivars first to make sure the synthesized ivars are indexed
+ // before indexing the methods that can reference them.
+ for (ObjCImplementationDecl::ivar_iterator
+ IvarI = D->ivar_begin(),
+ IvarE = D->ivar_end(); IvarI != IvarE; ++IvarI) {
+ IndexCtx.indexDecl(*IvarI);
+ }
+ for (DeclContext::decl_iterator
+ I = D->decls_begin(), E = D->decls_end(); I != E; ++I) {
+ if (!isa<ObjCIvarDecl>(*I))
+ IndexCtx.indexDecl(*I);
+ }
+
return true;
}
Modified: cfe/branches/tooling/tools/libclang/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/RecursiveASTVisitor.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/RecursiveASTVisitor.h (original)
+++ cfe/branches/tooling/tools/libclang/RecursiveASTVisitor.h Fri Jun 15 06:08:27 2012
@@ -1767,6 +1767,11 @@
// children() iterates over inputExpr and outputExpr.
})
+DEF_TRAVERSE_STMT(MSAsmStmt, {
+ // FIXME: MS Asm doesn't currently parse Constraints, Clobbers, etc. Once
+ // added this needs to be implemented.
+ })
+
DEF_TRAVERSE_STMT(CXXCatchStmt, {
TRY_TO(TraverseDecl(S->getExceptionDecl()));
// children() iterates over the handler block.
Propchange: cfe/branches/tooling/unittests/Tooling/CompilationDatabaseTest.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo (removed)
@@ -1,2 +0,0 @@
-/cfe/branches/type-system-rewrite/unittests/Tooling/CompilationDatabaseTest.cpp:134693-134817
-/cfe/trunk/test/SemaTemplate/unittests/Tooling/CompilationDatabaseTest.cpp:126920
Modified: cfe/branches/tooling/unittests/Tooling/RecursiveASTVisitorTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/unittests/Tooling/RecursiveASTVisitorTest.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/unittests/Tooling/RecursiveASTVisitorTest.cpp (original)
+++ cfe/branches/tooling/unittests/Tooling/RecursiveASTVisitorTest.cpp Fri Jun 15 06:08:27 2012
@@ -142,6 +142,14 @@
}
};
+class VarDeclVisitor : public ExpectedLocationVisitor<VarDeclVisitor> {
+public:
+ bool VisitVarDecl(VarDecl *Variable) {
+ Match(Variable->getNameAsString(), Variable->getLocStart());
+ return true;
+ }
+};
+
class CXXMemberCallVisitor
: public ExpectedLocationVisitor<CXXMemberCallVisitor> {
public:
@@ -250,6 +258,22 @@
"void x(); template <void (*T)()> class X {};\nX<x> y;"));
}
+TEST(RecursiveASTVisitor, VisitsCXXForRangeStmtRange) {
+ DeclRefExprVisitor Visitor;
+ Visitor.ExpectMatch("x", 2, 25);
+ EXPECT_TRUE(Visitor.runOver(
+ "int x[5];\n"
+ "void f() { for (int i : x) {} }"));
+}
+
+TEST(RecursiveASTVisitor, VisitsCXXForRangeStmtLoopVariable) {
+ VarDeclVisitor Visitor;
+ Visitor.ExpectMatch("i", 2, 17);
+ EXPECT_TRUE(Visitor.runOver(
+ "int x[5];\n"
+ "void f() { for (int i : x) {} }"));
+}
+
TEST(RecursiveASTVisitor, VisitsCallExpr) {
DeclRefExprVisitor Visitor;
Visitor.ExpectMatch("x", 1, 22);
@@ -452,7 +476,7 @@
class ImplicitCtorVisitor
: public ExpectedLocationVisitor<ImplicitCtorVisitor> {
public:
- bool shouldVisitImplicitDeclarations() const { return true; }
+ bool shouldVisitImplicitCode() const { return true; }
bool VisitCXXConstructorDecl(CXXConstructorDecl* Ctor) {
if (Ctor->isImplicit()) { // Was not written in source code
Modified: cfe/branches/tooling/unittests/Tooling/RewriterTestContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/unittests/Tooling/RewriterTestContext.h?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/unittests/Tooling/RewriterTestContext.h (original)
+++ cfe/branches/tooling/unittests/Tooling/RewriterTestContext.h Fri Jun 15 06:08:27 2012
@@ -21,6 +21,7 @@
#include "clang/Frontend/DiagnosticOptions.h"
#include "clang/Frontend/TextDiagnosticPrinter.h"
#include "clang/Rewrite/Rewriter.h"
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
@@ -43,6 +44,10 @@
}
~RewriterTestContext() {
+ if (!TemporaryDirectory.empty()) {
+ uint32_t RemovedCount = 0;
+ llvm::sys::fs::remove_all(TemporaryDirectory.str(), RemovedCount);
+ }
}
FileID createInMemoryFile(StringRef Name, StringRef Content) {
@@ -56,12 +61,16 @@
}
FileID createOnDiskFile(StringRef Name, StringRef Content) {
- if (!TemporaryDirectory.isValid()) {
- std::string ErrorInfo;
- TemporaryDirectory = llvm::sys::Path::GetTemporaryDirectory(&ErrorInfo);
- assert(ErrorInfo.empty());
+ if (TemporaryDirectory.empty()) {
+ int FD;
+ bool error =
+ llvm::sys::fs::unique_file("rewriter-test-%%-%%-%%-%%/anchor", FD,
+ TemporaryDirectory);
+ assert(!error); (void)error;
+ llvm::raw_fd_ostream Closer(FD, /*shouldClose=*/true);
+ TemporaryDirectory = llvm::sys::path::parent_path(TemporaryDirectory);
}
- llvm::SmallString<1024> Path(TemporaryDirectory.str());
+ llvm::SmallString<1024> Path(TemporaryDirectory);
llvm::sys::path::append(Path, Name);
std::string ErrorInfo;
llvm::raw_fd_ostream OutStream(Path.c_str(),
@@ -107,8 +116,8 @@
LangOptions Options;
Rewriter Rewrite;
- // Will be set once on disk files are generated.
- llvm::sys::Path TemporaryDirectory;
+ // Will be set once on disk files are generated.
+ SmallString<128> TemporaryDirectory;
};
} // end namespace clang
Propchange: cfe/branches/tooling/unittests/Tooling/ToolingTest.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo (removed)
@@ -1,2 +0,0 @@
-/cfe/branches/type-system-rewrite/unittests/Tooling/ToolingTest.cpp:134693-134817
-/cfe/trunk/test/SemaTemplate/unittests/Tooling/ToolingTest.cpp:126920
Modified: cfe/branches/tooling/utils/TableGen/ClangASTNodesEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/utils/TableGen/ClangASTNodesEmitter.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/utils/TableGen/ClangASTNodesEmitter.cpp (original)
+++ cfe/branches/tooling/utils/TableGen/ClangASTNodesEmitter.cpp Fri Jun 15 06:08:27 2012
@@ -11,10 +11,58 @@
//
//===----------------------------------------------------------------------===//
-#include "ClangASTNodesEmitter.h"
+#include "llvm/TableGen/Record.h"
+#include "llvm/TableGen/TableGenBackend.h"
+#include <cctype>
+#include <map>
#include <set>
+#include <string>
using namespace llvm;
+/// ClangASTNodesEmitter - The top-level class emits .inc files containing
+/// declarations of Clang statements.
+///
+namespace {
+class ClangASTNodesEmitter {
+ // A map from a node to each of its derived nodes.
+ typedef std::multimap<Record*, Record*> ChildMap;
+ typedef ChildMap::const_iterator ChildIterator;
+
+ RecordKeeper &Records;
+ Record Root;
+ const std::string &BaseSuffix;
+
+ // Create a macro-ized version of a name
+ static std::string macroName(std::string S) {
+ for (unsigned i = 0; i < S.size(); ++i)
+ S[i] = std::toupper(S[i]);
+
+ return S;
+ }
+
+ // Return the name to be printed in the base field. Normally this is
+ // the record's name plus the base suffix, but if it is the root node and
+ // the suffix is non-empty, it's just the suffix.
+ std::string baseName(Record &R) {
+ if (&R == &Root && !BaseSuffix.empty())
+ return BaseSuffix;
+
+ return R.getName() + BaseSuffix;
+ }
+
+ std::pair<Record *, Record *> EmitNode (const ChildMap &Tree, raw_ostream& OS,
+ Record *Base);
+public:
+ explicit ClangASTNodesEmitter(RecordKeeper &R, const std::string &N,
+ const std::string &S)
+ : Records(R), Root(N, SMLoc(), R), BaseSuffix(S)
+ {}
+
+ // run - Output the .inc file contents
+ void run(raw_ostream &OS);
+};
+} // end anonymous namespace
+
//===----------------------------------------------------------------------===//
// Statement Node Tables (.inc file) generation.
//===----------------------------------------------------------------------===//
@@ -124,7 +172,15 @@
OS << "#undef ABSTRACT_" << macroName(Root.getName()) << "\n";
}
-void ClangDeclContextEmitter::run(raw_ostream &OS) {
+namespace clang {
+void EmitClangASTNodes(RecordKeeper &RK, raw_ostream &OS,
+ const std::string &N, const std::string &S) {
+ ClangASTNodesEmitter(RK, N, S).run(OS);
+}
+
+// Emits and addendum to a .inc file to enumerate the clang declaration
+// contexts.
+void EmitClangDeclContext(RecordKeeper &Records, raw_ostream &OS) {
// FIXME: Find a .td file format to allow for this to be represented better.
OS << "#ifndef DECL_CONTEXT\n";
@@ -166,3 +222,4 @@
OS << "#undef DECL_CONTEXT\n";
OS << "#undef DECL_CONTEXT_BASE\n";
}
+} // end namespace clang
Removed: cfe/branches/tooling/utils/TableGen/ClangASTNodesEmitter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/utils/TableGen/ClangASTNodesEmitter.h?rev=158514&view=auto
==============================================================================
--- cfe/branches/tooling/utils/TableGen/ClangASTNodesEmitter.h (original)
+++ cfe/branches/tooling/utils/TableGen/ClangASTNodesEmitter.h (removed)
@@ -1,84 +0,0 @@
-//===- ClangASTNodesEmitter.h - Generate Clang AST node tables -*- C++ -*--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// These tablegen backends emit Clang AST node tables
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef CLANGAST_EMITTER_H
-#define CLANGAST_EMITTER_H
-
-#include "llvm/TableGen/TableGenBackend.h"
-#include "llvm/TableGen/Record.h"
-#include <string>
-#include <cctype>
-#include <map>
-
-namespace llvm {
-
-/// ClangASTNodesEmitter - The top-level class emits .inc files containing
-/// declarations of Clang statements.
-///
-class ClangASTNodesEmitter : public TableGenBackend {
- // A map from a node to each of its derived nodes.
- typedef std::multimap<Record*, Record*> ChildMap;
- typedef ChildMap::const_iterator ChildIterator;
-
- RecordKeeper &Records;
- Record Root;
- const std::string &BaseSuffix;
-
- // Create a macro-ized version of a name
- static std::string macroName(std::string S) {
- for (unsigned i = 0; i < S.size(); ++i)
- S[i] = std::toupper(S[i]);
-
- return S;
- }
-
- // Return the name to be printed in the base field. Normally this is
- // the record's name plus the base suffix, but if it is the root node and
- // the suffix is non-empty, it's just the suffix.
- std::string baseName(Record &R) {
- if (&R == &Root && !BaseSuffix.empty())
- return BaseSuffix;
-
- return R.getName() + BaseSuffix;
- }
-
- std::pair<Record *, Record *> EmitNode (const ChildMap &Tree, raw_ostream& OS,
- Record *Base);
-public:
- explicit ClangASTNodesEmitter(RecordKeeper &R, const std::string &N,
- const std::string &S)
- : Records(R), Root(N, SMLoc(), R), BaseSuffix(S)
- {}
-
- // run - Output the .inc file contents
- void run(raw_ostream &OS);
-};
-
-/// ClangDeclContextEmitter - Emits an addendum to a .inc file to enumerate the
-/// clang declaration contexts.
-///
-class ClangDeclContextEmitter : public TableGenBackend {
- RecordKeeper &Records;
-
-public:
- explicit ClangDeclContextEmitter(RecordKeeper &R)
- : Records(R)
- {}
-
- // run - Output the .inc file contents
- void run(raw_ostream &OS);
-};
-
-} // End llvm namespace
-
-#endif
Modified: cfe/branches/tooling/utils/TableGen/ClangAttrEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/utils/TableGen/ClangAttrEmitter.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/branches/tooling/utils/TableGen/ClangAttrEmitter.cpp Fri Jun 15 06:08:27 2012
@@ -11,10 +11,10 @@
//
//===----------------------------------------------------------------------===//
-#include "ClangAttrEmitter.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/TableGen/Record.h"
#include "llvm/TableGen/StringMatcher.h"
+#include "llvm/TableGen/TableGenBackend.h"
#include <algorithm>
#include <cctype>
#include <set>
@@ -661,7 +661,10 @@
<< " OS << \"";
}
-void ClangAttrClassEmitter::run(raw_ostream &OS) {
+namespace clang {
+
+// Emits the class definitions for attributes.
+void EmitClangAttrClass(RecordKeeper &Records, raw_ostream &OS) {
OS << "// This file is generated by TableGen. Do not edit.\n\n";
OS << "#ifndef LLVM_CLANG_ATTR_CLASSES_INC\n";
OS << "#define LLVM_CLANG_ATTR_CLASSES_INC\n\n";
@@ -750,7 +753,8 @@
OS << "#endif\n";
}
-void ClangAttrImplEmitter::run(raw_ostream &OS) {
+// Emits the class method definitions for attributes.
+void EmitClangAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
OS << "// This file is generated by TableGen. Do not edit.\n\n";
std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr");
@@ -801,6 +805,8 @@
}
}
+} // end namespace clang
+
static void EmitAttrList(raw_ostream &OS, StringRef Class,
const std::vector<Record*> &AttrList) {
std::vector<Record*>::const_iterator i = AttrList.begin(), e = AttrList.end();
@@ -818,7 +824,10 @@
}
}
-void ClangAttrListEmitter::run(raw_ostream &OS) {
+namespace clang {
+
+// Emits the enumeration list for attributes.
+void EmitClangAttrList(RecordKeeper &Records, raw_ostream &OS) {
OS << "// This file is generated by TableGen. Do not edit.\n\n";
OS << "#ifndef LAST_ATTR\n";
@@ -870,7 +879,8 @@
OS << "#undef ATTR\n";
}
-void ClangAttrPCHReadEmitter::run(raw_ostream &OS) {
+// Emits the code to read an attribute from a precompiled header.
+void EmitClangAttrPCHRead(RecordKeeper &Records, raw_ostream &OS) {
OS << "// This file is generated by TableGen. Do not edit.\n\n";
Record *InhClass = Records.getClass("InheritableAttr");
@@ -913,7 +923,8 @@
OS << " }\n";
}
-void ClangAttrPCHWriteEmitter::run(raw_ostream &OS) {
+// Emits the code to write an attribute to a precompiled header.
+void EmitClangAttrPCHWrite(RecordKeeper &Records, raw_ostream &OS) {
Record *InhClass = Records.getClass("InheritableAttr");
std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr"), Args;
std::vector<Record*>::iterator i = Attrs.begin(), e = Attrs.end(), ai, ae;
@@ -941,7 +952,8 @@
OS << " }\n";
}
-void ClangAttrSpellingListEmitter::run(raw_ostream &OS) {
+// Emits the list of spellings for attributes.
+void EmitClangAttrSpellingList(RecordKeeper &Records, raw_ostream &OS) {
OS << "// This file is generated by TableGen. Do not edit.\n\n";
std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr");
@@ -959,7 +971,8 @@
}
-void ClangAttrLateParsedListEmitter::run(raw_ostream &OS) {
+// Emits the LateParsed property for attributes.
+void EmitClangAttrLateParsedList(RecordKeeper &Records, raw_ostream &OS) {
OS << "// This file is generated by TableGen. Do not edit.\n\n";
std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr");
@@ -982,8 +995,8 @@
}
}
-
-void ClangAttrTemplateInstantiateEmitter::run(raw_ostream &OS) {
+// Emits code to instantiate dependent attributes on templates.
+void EmitClangAttrTemplateInstantiate(RecordKeeper &Records, raw_ostream &OS) {
OS << "// This file is generated by TableGen. Do not edit.\n\n";
std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr");
@@ -1055,7 +1068,8 @@
<< "} // end namespace clang\n";
}
-void ClangAttrParsedAttrListEmitter::run(raw_ostream &OS) {
+// Emits the list of parsed attributes.
+void EmitClangAttrParsedAttrList(RecordKeeper &Records, raw_ostream &OS) {
OS << "// This file is generated by TableGen. Do not edit.\n\n";
OS << "#ifndef PARSED_ATTR\n";
@@ -1096,7 +1110,8 @@
}
}
-void ClangAttrParsedAttrKindsEmitter::run(raw_ostream &OS) {
+// Emits the kind list of parsed attributes
+void EmitClangAttrParsedAttrKinds(RecordKeeper &Records, raw_ostream &OS) {
OS << "// This file is generated by TableGen. Do not edit.\n\n";
OS << "\n";
@@ -1141,4 +1156,4 @@
<< "}\n";
}
-
+} // end namespace clang
Modified: cfe/branches/tooling/utils/TableGen/ClangDiagnosticsEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/utils/TableGen/ClangDiagnosticsEmitter.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/utils/TableGen/ClangDiagnosticsEmitter.cpp (original)
+++ cfe/branches/tooling/utils/TableGen/ClangDiagnosticsEmitter.cpp Fri Jun 15 06:08:27 2012
@@ -11,16 +11,16 @@
//
//===----------------------------------------------------------------------===//
-#include "ClangDiagnosticsEmitter.h"
-#include "llvm/TableGen/Record.h"
-#include "llvm/Support/Debug.h"
-#include "llvm/Support/Compiler.h"
#include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/SmallString.h"
-#include <map>
+#include "llvm/ADT/StringMap.h"
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/TableGen/Record.h"
+#include "llvm/TableGen/TableGenBackend.h"
#include <algorithm>
#include <functional>
+#include <map>
#include <set>
using namespace llvm;
@@ -163,7 +163,11 @@
// Warning Tables (.inc file) generation.
//===----------------------------------------------------------------------===//
-void ClangDiagsDefsEmitter::run(raw_ostream &OS) {
+/// ClangDiagsDefsEmitter - The top-level class emits .def files containing
+/// declarations of Clang diagnostics.
+namespace clang {
+void EmitClangDiagsDefs(RecordKeeper &Records, raw_ostream &OS,
+ const std::string &Component) {
// Write the #if guard
if (!Component.empty()) {
std::string ComponentName = StringRef(Component).upper();
@@ -244,6 +248,7 @@
OS << ")\n";
}
}
+} // end namespace clang
//===----------------------------------------------------------------------===//
// Warning Group Tables generation
@@ -258,7 +263,8 @@
return enumName.str();
}
-void ClangDiagGroupsEmitter::run(raw_ostream &OS) {
+namespace clang {
+void EmitClangDiagGroups(RecordKeeper &Records, raw_ostream &OS) {
// Compute a mapping from a DiagGroup to all of its parents.
DiagGroupParentMap DGParentMap(Records);
@@ -339,6 +345,7 @@
OS << "CATEGORY(\"" << *I << "\", " << getDiagCategoryEnum(*I) << ")\n";
OS << "#endif // GET_CATEGORY_TABLE\n\n";
}
+} // end namespace clang
//===----------------------------------------------------------------------===//
// Diagnostic name index generation
@@ -366,7 +373,8 @@
} // end anonymous namespace.
-void ClangDiagsIndexNameEmitter::run(raw_ostream &OS) {
+namespace clang {
+void EmitClangDiagsIndexName(RecordKeeper &Records, raw_ostream &OS) {
const std::vector<Record*> &Diags =
Records.getAllDerivedDefinitions("Diagnostic");
@@ -385,3 +393,4 @@
OS << "DIAG_NAME_INDEX(" << R.Name << ")\n";
}
}
+} // end namespace clang
Removed: cfe/branches/tooling/utils/TableGen/ClangDiagnosticsEmitter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/utils/TableGen/ClangDiagnosticsEmitter.h?rev=158514&view=auto
==============================================================================
--- cfe/branches/tooling/utils/TableGen/ClangDiagnosticsEmitter.h (original)
+++ cfe/branches/tooling/utils/TableGen/ClangDiagnosticsEmitter.h (removed)
@@ -1,54 +0,0 @@
-//===- ClangDiagnosticsEmitter.h - Generate Clang diagnostics tables -*- C++ -*-
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// These tablegen backends emit Clang diagnostics tables.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef CLANGDIAGS_EMITTER_H
-#define CLANGDIAGS_EMITTER_H
-
-#include "llvm/TableGen/TableGenBackend.h"
-
-namespace llvm {
-
-/// ClangDiagsDefsEmitter - The top-level class emits .def files containing
-/// declarations of Clang diagnostics.
-///
-class ClangDiagsDefsEmitter : public TableGenBackend {
- RecordKeeper &Records;
- const std::string& Component;
-public:
- explicit ClangDiagsDefsEmitter(RecordKeeper &R, const std::string& component)
- : Records(R), Component(component) {}
-
- // run - Output the .def file contents
- void run(raw_ostream &OS);
-};
-
-class ClangDiagGroupsEmitter : public TableGenBackend {
- RecordKeeper &Records;
-public:
- explicit ClangDiagGroupsEmitter(RecordKeeper &R) : Records(R) {}
-
- void run(raw_ostream &OS);
-};
-
-class ClangDiagsIndexNameEmitter : public TableGenBackend {
- RecordKeeper &Records;
-public:
- explicit ClangDiagsIndexNameEmitter(RecordKeeper &R) : Records(R) {}
-
- void run(raw_ostream &OS);
-};
-
-
-} // End llvm namespace
-
-#endif
Modified: cfe/branches/tooling/utils/TableGen/ClangSACheckersEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/utils/TableGen/ClangSACheckersEmitter.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/utils/TableGen/ClangSACheckersEmitter.cpp (original)
+++ cfe/branches/tooling/utils/TableGen/ClangSACheckersEmitter.cpp Fri Jun 15 06:08:27 2012
@@ -11,9 +11,9 @@
//
//===----------------------------------------------------------------------===//
-#include "ClangSACheckersEmitter.h"
-#include "llvm/TableGen/Record.h"
#include "llvm/ADT/DenseSet.h"
+#include "llvm/TableGen/Record.h"
+#include "llvm/TableGen/TableGenBackend.h"
#include <map>
#include <string>
using namespace llvm;
@@ -93,7 +93,8 @@
addPackageToCheckerGroup(*I, group, recordGroupMap);
}
-void ClangSACheckersEmitter::run(raw_ostream &OS) {
+namespace clang {
+void EmitClangSACheckers(RecordKeeper &Records, raw_ostream &OS) {
std::vector<Record*> checkers = Records.getAllDerivedDefinitions("Checker");
llvm::DenseMap<const Record *, unsigned> checkerRecIndexMap;
for (unsigned i = 0, e = checkers.size(); i != e; ++i)
@@ -317,3 +318,4 @@
}
OS << "#endif // GET_CHECKNAME_TABLE\n\n";
}
+} // end namespace clang
Removed: cfe/branches/tooling/utils/TableGen/ClangSACheckersEmitter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/utils/TableGen/ClangSACheckersEmitter.h?rev=158514&view=auto
==============================================================================
--- cfe/branches/tooling/utils/TableGen/ClangSACheckersEmitter.h (original)
+++ cfe/branches/tooling/utils/TableGen/ClangSACheckersEmitter.h (removed)
@@ -1,31 +0,0 @@
-//===- ClangSACheckersEmitter.h - Generate Clang SA checkers tables -*- C++ -*-
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This tablegen backend emits Clang Static Analyzer checkers tables.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef CLANGSACHECKERS_EMITTER_H
-#define CLANGSACHECKERS_EMITTER_H
-
-#include "llvm/TableGen/TableGenBackend.h"
-
-namespace llvm {
-
-class ClangSACheckersEmitter : public TableGenBackend {
- RecordKeeper &Records;
-public:
- explicit ClangSACheckersEmitter(RecordKeeper &R) : Records(R) {}
-
- void run(raw_ostream &OS);
-};
-
-} // End llvm namespace
-
-#endif
Modified: cfe/branches/tooling/utils/TableGen/NeonEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/utils/TableGen/NeonEmitter.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/utils/TableGen/NeonEmitter.cpp (original)
+++ cfe/branches/tooling/utils/TableGen/NeonEmitter.cpp Fri Jun 15 06:08:27 2012
@@ -23,16 +23,206 @@
//
//===----------------------------------------------------------------------===//
-#include "NeonEmitter.h"
-#include "llvm/TableGen/Error.h"
+#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringMap.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/TableGen/Error.h"
+#include "llvm/TableGen/Record.h"
+#include "llvm/TableGen/TableGenBackend.h"
#include <string>
-
using namespace llvm;
+enum OpKind {
+ OpNone,
+ OpUnavailable,
+ OpAdd,
+ OpAddl,
+ OpAddw,
+ OpSub,
+ OpSubl,
+ OpSubw,
+ OpMul,
+ OpMla,
+ OpMlal,
+ OpMls,
+ OpMlsl,
+ OpMulN,
+ OpMlaN,
+ OpMlsN,
+ OpMlalN,
+ OpMlslN,
+ OpMulLane,
+ OpMullLane,
+ OpMlaLane,
+ OpMlsLane,
+ OpMlalLane,
+ OpMlslLane,
+ OpQDMullLane,
+ OpQDMlalLane,
+ OpQDMlslLane,
+ OpQDMulhLane,
+ OpQRDMulhLane,
+ OpEq,
+ OpGe,
+ OpLe,
+ OpGt,
+ OpLt,
+ OpNeg,
+ OpNot,
+ OpAnd,
+ OpOr,
+ OpXor,
+ OpAndNot,
+ OpOrNot,
+ OpCast,
+ OpConcat,
+ OpDup,
+ OpDupLane,
+ OpHi,
+ OpLo,
+ OpSelect,
+ OpRev16,
+ OpRev32,
+ OpRev64,
+ OpReinterpret,
+ OpAbdl,
+ OpAba,
+ OpAbal
+};
+
+enum ClassKind {
+ ClassNone,
+ ClassI, // generic integer instruction, e.g., "i8" suffix
+ ClassS, // signed/unsigned/poly, e.g., "s8", "u8" or "p8" suffix
+ ClassW, // width-specific instruction, e.g., "8" suffix
+ ClassB // bitcast arguments with enum argument to specify type
+};
+
+/// NeonTypeFlags - Flags to identify the types for overloaded Neon
+/// builtins. These must be kept in sync with the flags in
+/// include/clang/Basic/TargetBuiltins.h.
+namespace {
+class NeonTypeFlags {
+ enum {
+ EltTypeMask = 0xf,
+ UnsignedFlag = 0x10,
+ QuadFlag = 0x20
+ };
+ uint32_t Flags;
+
+public:
+ enum EltType {
+ Int8,
+ Int16,
+ Int32,
+ Int64,
+ Poly8,
+ Poly16,
+ Float16,
+ Float32
+ };
+
+ NeonTypeFlags(unsigned F) : Flags(F) {}
+ NeonTypeFlags(EltType ET, bool IsUnsigned, bool IsQuad) : Flags(ET) {
+ if (IsUnsigned)
+ Flags |= UnsignedFlag;
+ if (IsQuad)
+ Flags |= QuadFlag;
+ }
+
+ uint32_t getFlags() const { return Flags; }
+};
+} // end anonymous namespace
+
+namespace {
+class NeonEmitter {
+ RecordKeeper &Records;
+ StringMap<OpKind> OpMap;
+ DenseMap<Record*, ClassKind> ClassMap;
+
+public:
+ NeonEmitter(RecordKeeper &R) : Records(R) {
+ OpMap["OP_NONE"] = OpNone;
+ OpMap["OP_UNAVAILABLE"] = OpUnavailable;
+ OpMap["OP_ADD"] = OpAdd;
+ OpMap["OP_ADDL"] = OpAddl;
+ OpMap["OP_ADDW"] = OpAddw;
+ OpMap["OP_SUB"] = OpSub;
+ OpMap["OP_SUBL"] = OpSubl;
+ OpMap["OP_SUBW"] = OpSubw;
+ OpMap["OP_MUL"] = OpMul;
+ OpMap["OP_MLA"] = OpMla;
+ OpMap["OP_MLAL"] = OpMlal;
+ OpMap["OP_MLS"] = OpMls;
+ OpMap["OP_MLSL"] = OpMlsl;
+ OpMap["OP_MUL_N"] = OpMulN;
+ OpMap["OP_MLA_N"] = OpMlaN;
+ OpMap["OP_MLS_N"] = OpMlsN;
+ OpMap["OP_MLAL_N"] = OpMlalN;
+ OpMap["OP_MLSL_N"] = OpMlslN;
+ OpMap["OP_MUL_LN"]= OpMulLane;
+ OpMap["OP_MULL_LN"] = OpMullLane;
+ OpMap["OP_MLA_LN"]= OpMlaLane;
+ OpMap["OP_MLS_LN"]= OpMlsLane;
+ OpMap["OP_MLAL_LN"] = OpMlalLane;
+ OpMap["OP_MLSL_LN"] = OpMlslLane;
+ OpMap["OP_QDMULL_LN"] = OpQDMullLane;
+ OpMap["OP_QDMLAL_LN"] = OpQDMlalLane;
+ OpMap["OP_QDMLSL_LN"] = OpQDMlslLane;
+ OpMap["OP_QDMULH_LN"] = OpQDMulhLane;
+ OpMap["OP_QRDMULH_LN"] = OpQRDMulhLane;
+ OpMap["OP_EQ"] = OpEq;
+ OpMap["OP_GE"] = OpGe;
+ OpMap["OP_LE"] = OpLe;
+ OpMap["OP_GT"] = OpGt;
+ OpMap["OP_LT"] = OpLt;
+ OpMap["OP_NEG"] = OpNeg;
+ OpMap["OP_NOT"] = OpNot;
+ OpMap["OP_AND"] = OpAnd;
+ OpMap["OP_OR"] = OpOr;
+ OpMap["OP_XOR"] = OpXor;
+ OpMap["OP_ANDN"] = OpAndNot;
+ OpMap["OP_ORN"] = OpOrNot;
+ OpMap["OP_CAST"] = OpCast;
+ OpMap["OP_CONC"] = OpConcat;
+ OpMap["OP_HI"] = OpHi;
+ OpMap["OP_LO"] = OpLo;
+ OpMap["OP_DUP"] = OpDup;
+ OpMap["OP_DUP_LN"] = OpDupLane;
+ OpMap["OP_SEL"] = OpSelect;
+ OpMap["OP_REV16"] = OpRev16;
+ OpMap["OP_REV32"] = OpRev32;
+ OpMap["OP_REV64"] = OpRev64;
+ OpMap["OP_REINT"] = OpReinterpret;
+ OpMap["OP_ABDL"] = OpAbdl;
+ OpMap["OP_ABA"] = OpAba;
+ OpMap["OP_ABAL"] = OpAbal;
+
+ Record *SI = R.getClass("SInst");
+ Record *II = R.getClass("IInst");
+ Record *WI = R.getClass("WInst");
+ ClassMap[SI] = ClassS;
+ ClassMap[II] = ClassI;
+ ClassMap[WI] = ClassW;
+ }
+
+ // run - Emit arm_neon.h.inc
+ void run(raw_ostream &o);
+
+ // runHeader - Emit all the __builtin prototypes used in arm_neon.h
+ void runHeader(raw_ostream &o);
+
+ // runTests - Emit tests for all the Neon intrinsics.
+ void runTests(raw_ostream &o);
+
+private:
+ void emitIntrinsic(raw_ostream &OS, Record *R);
+};
+} // end anonymous namespace
+
/// ParseTypes - break down a string such as "fQf" into a vector of StringRefs,
/// which each StringRef representing a single type declared in the string.
/// for "fQf" we would end up with 2 StringRefs, "f", and "Qf", representing
@@ -1576,3 +1766,14 @@
}
}
+namespace clang {
+void EmitNeon(RecordKeeper &Records, raw_ostream &OS) {
+ NeonEmitter(Records).run(OS);
+}
+void EmitNeonSema(RecordKeeper &Records, raw_ostream &OS) {
+ NeonEmitter(Records).runHeader(OS);
+}
+void EmitNeonTest(RecordKeeper &Records, raw_ostream &OS) {
+ NeonEmitter(Records).runTests(OS);
+}
+} // End namespace clang
Modified: cfe/branches/tooling/utils/TableGen/OptParserEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/utils/TableGen/OptParserEmitter.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/utils/TableGen/OptParserEmitter.cpp (original)
+++ cfe/branches/tooling/utils/TableGen/OptParserEmitter.cpp Fri Jun 15 06:08:27 2012
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#include "OptParserEmitter.h"
#include "llvm/TableGen/Record.h"
+#include "llvm/TableGen/TableGenBackend.h"
#include "llvm/ADT/STLExtras.h"
using namespace llvm;
@@ -69,16 +69,20 @@
return OS;
}
-void OptParserEmitter::run(raw_ostream &OS) {
+/// OptParserEmitter - This tablegen backend takes an input .td file
+/// describing a list of options and emits a data structure for parsing and
+/// working with those options when given an input command line.
+namespace clang {
+void EmitOptParser(RecordKeeper &Records, raw_ostream &OS, bool GenDefs) {
// Get the option groups and options.
const std::vector<Record*> &Groups =
Records.getAllDerivedDefinitions("OptionGroup");
std::vector<Record*> Opts = Records.getAllDerivedDefinitions("Option");
if (GenDefs)
- EmitSourceFileHeader("Option Parsing Definitions", OS);
+ emitSourceFileHeader("Option Parsing Definitions", OS);
else
- EmitSourceFileHeader("Option Parsing Table", OS);
+ emitSourceFileHeader("Option Parsing Table", OS);
array_pod_sort(Opts.begin(), Opts.end(), CompareOptionRecords);
if (GenDefs) {
@@ -192,3 +196,4 @@
}
}
}
+} // end namespace clang
Removed: cfe/branches/tooling/utils/TableGen/OptParserEmitter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/utils/TableGen/OptParserEmitter.h?rev=158514&view=auto
==============================================================================
--- cfe/branches/tooling/utils/TableGen/OptParserEmitter.h (original)
+++ cfe/branches/tooling/utils/TableGen/OptParserEmitter.h (removed)
@@ -1,34 +0,0 @@
-//===- OptParserEmitter.h - Table Driven Command Line Parsing ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef UTILS_TABLEGEN_OPTPARSEREMITTER_H
-#define UTILS_TABLEGEN_OPTPARSEREMITTER_H
-
-#include "llvm/TableGen/TableGenBackend.h"
-
-namespace llvm {
- /// OptParserEmitter - This tablegen backend takes an input .td file
- /// describing a list of options and emits a data structure for parsing and
- /// working with those options when given an input command line.
- class OptParserEmitter : public TableGenBackend {
- RecordKeeper &Records;
- bool GenDefs;
-
- public:
- OptParserEmitter(RecordKeeper &R, bool _GenDefs)
- : Records(R), GenDefs(_GenDefs) {}
-
- /// run - Output the option parsing information.
- ///
- /// \param GenHeader - Generate the header describing the option IDs.x
- void run(raw_ostream &OS);
- };
-}
-
-#endif
Modified: cfe/branches/tooling/utils/TableGen/TableGen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/utils/TableGen/TableGen.cpp?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/utils/TableGen/TableGen.cpp (original)
+++ cfe/branches/tooling/utils/TableGen/TableGen.cpp Fri Jun 15 06:08:27 2012
@@ -11,12 +11,7 @@
//
//===----------------------------------------------------------------------===//
-#include "ClangASTNodesEmitter.h"
-#include "ClangAttrEmitter.h"
-#include "ClangDiagnosticsEmitter.h"
-#include "ClangSACheckersEmitter.h"
-#include "NeonEmitter.h"
-#include "OptParserEmitter.h"
+#include "TableGenBackends.h" // Declares all backends.
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/PrettyStackTrace.h"
@@ -27,6 +22,7 @@
#include "llvm/TableGen/TableGenAction.h"
using namespace llvm;
+using namespace clang;
enum ActionType {
GenClangAttrClasses,
@@ -114,68 +110,68 @@
bool operator()(raw_ostream &OS, RecordKeeper &Records) {
switch (Action) {
case GenClangAttrClasses:
- ClangAttrClassEmitter(Records).run(OS);
+ EmitClangAttrClass(Records, OS);
break;
case GenClangAttrImpl:
- ClangAttrImplEmitter(Records).run(OS);
+ EmitClangAttrImpl(Records, OS);
break;
case GenClangAttrList:
- ClangAttrListEmitter(Records).run(OS);
+ EmitClangAttrList(Records, OS);
break;
case GenClangAttrPCHRead:
- ClangAttrPCHReadEmitter(Records).run(OS);
+ EmitClangAttrPCHRead(Records, OS);
break;
case GenClangAttrPCHWrite:
- ClangAttrPCHWriteEmitter(Records).run(OS);
+ EmitClangAttrPCHWrite(Records, OS);
break;
case GenClangAttrSpellingList:
- ClangAttrSpellingListEmitter(Records).run(OS);
+ EmitClangAttrSpellingList(Records, OS);
break;
case GenClangAttrLateParsedList:
- ClangAttrLateParsedListEmitter(Records).run(OS);
+ EmitClangAttrLateParsedList(Records, OS);
break;
case GenClangAttrTemplateInstantiate:
- ClangAttrTemplateInstantiateEmitter(Records).run(OS);
+ EmitClangAttrTemplateInstantiate(Records, OS);
break;
case GenClangAttrParsedAttrList:
- ClangAttrParsedAttrListEmitter(Records).run(OS);
+ EmitClangAttrParsedAttrList(Records, OS);
break;
case GenClangAttrParsedAttrKinds:
- ClangAttrParsedAttrKindsEmitter(Records).run(OS);
+ EmitClangAttrParsedAttrKinds(Records, OS);
break;
case GenClangDiagsDefs:
- ClangDiagsDefsEmitter(Records, ClangComponent).run(OS);
+ EmitClangDiagsDefs(Records, OS, ClangComponent);
break;
case GenClangDiagGroups:
- ClangDiagGroupsEmitter(Records).run(OS);
+ EmitClangDiagGroups(Records, OS);
break;
case GenClangDiagsIndexName:
- ClangDiagsIndexNameEmitter(Records).run(OS);
+ EmitClangDiagsIndexName(Records, OS);
break;
case GenClangDeclNodes:
- ClangASTNodesEmitter(Records, "Decl", "Decl").run(OS);
- ClangDeclContextEmitter(Records).run(OS);
+ EmitClangASTNodes(Records, OS, "Decl", "Decl");
+ EmitClangDeclContext(Records, OS);
break;
case GenClangStmtNodes:
- ClangASTNodesEmitter(Records, "Stmt", "").run(OS);
+ EmitClangASTNodes(Records, OS, "Stmt", "");
break;
case GenClangSACheckers:
- ClangSACheckersEmitter(Records).run(OS);
+ EmitClangSACheckers(Records, OS);
break;
case GenOptParserDefs:
- OptParserEmitter(Records, true).run(OS);
+ EmitOptParser(Records, OS, true);
break;
case GenOptParserImpl:
- OptParserEmitter(Records, false).run(OS);
+ EmitOptParser(Records, OS, false);
break;
case GenArmNeon:
- NeonEmitter(Records).run(OS);
+ EmitNeon(Records, OS);
break;
case GenArmNeonSema:
- NeonEmitter(Records).runHeader(OS);
+ EmitNeonSema(Records, OS);
break;
case GenArmNeonTest:
- NeonEmitter(Records).runTests(OS);
+ EmitNeonTest(Records, OS);
break;
}
Modified: cfe/branches/tooling/utils/analyzer/CmpRuns.py
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/utils/analyzer/CmpRuns.py?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/utils/analyzer/CmpRuns.py (original)
+++ cfe/branches/tooling/utils/analyzer/CmpRuns.py Fri Jun 15 06:08:27 2012
@@ -134,6 +134,14 @@
return run
+def getIssueIdentifier(d) :
+ id = ''
+ if 'issue_context' in d.data :
+ id += d.data['issue_context']
+ if 'issue_hash' in d.data :
+ id += str(d.data['issue_hash'])
+ return id
+
def compareResults(A, B):
"""
compareResults - Generate a relation from diagnostics in run A to
@@ -152,12 +160,12 @@
neqB = []
eltsA = list(A.diagnostics)
eltsB = list(B.diagnostics)
- eltsA.sort(key = lambda d: d.data)
- eltsB.sort(key = lambda d: d.data)
+ eltsA.sort(key = getIssueIdentifier)
+ eltsB.sort(key = getIssueIdentifier)
while eltsA and eltsB:
a = eltsA.pop()
b = eltsB.pop()
- if a.data['location'] == b.data['location']:
+ if (getIssueIdentifier(a) == getIssueIdentifier(b)) :
res.append((a, b, 0))
elif a.data > b.data:
neqA.append(a)
Modified: cfe/branches/tooling/utils/clang-completion-mode.el
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/utils/clang-completion-mode.el?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/utils/clang-completion-mode.el (original)
+++ cfe/branches/tooling/utils/clang-completion-mode.el Fri Jun 15 06:08:27 2012
@@ -32,8 +32,12 @@
;;
;; (load-library "clang-completion-mode")
;;
+;; Once you have done this, you can set various parameters with
+;;
+;; M-x customize-group RET clang-completion-mode RET
+;;
;; Finally, to try Clang-based code completion in a particular buffer,
-;; use M-x clang-completion-mode. When "Clang-CC" shows up in the mode
+;; use M-x clang-completion-mode. When "Clang" shows up in the mode
;; line, Clang's code-completion is enabled.
;;
;; Clang's code completion is based on parsing the complete source
@@ -100,7 +104,12 @@
(or (string-match "OVERLOAD:" line)
(string-match (concat "COMPLETION: " clang-completion-substring) line)))
+
+;; re-process the completions when further input narrows the field
(defun clang-completion-display (buffer)
+ (fill-buffer buffer))
+
+(defun fill-buffer (buffer)
(let* ((all-lines (split-string clang-result-string "\n"))
(completion-lines (filter 'is-completion-line all-lines)))
(if (consp completion-lines)
@@ -124,24 +133,7 @@
;; contents of the code-completion buffer with the new code-completion results
;; and ensures that the buffer is visible.
(defun clang-completion-sentinel (proc event)
- (let* ((all-lines (split-string clang-result-string "\n"))
- (completion-lines (filter 'is-completion-line all-lines)))
- (if (consp completion-lines)
- (progn
- ;; Erase the process buffer.
- (let ((cur (current-buffer)))
- (set-buffer (process-buffer proc))
- (goto-char (point-min))
- (erase-buffer)
- (set-buffer cur))
-
- ;; Display the process buffer.
- (display-buffer (process-buffer proc))
-
- ;; Insert the code-completion string into the process buffer.
- (with-current-buffer (process-buffer proc)
- (insert (mapconcat 'identity completion-lines "\n")))
- ))))
+ (fill-buffer (process-buffer proc)))
(defun clang-complete ()
(let* ((cc-point (concat (buffer-file-name)
Modified: cfe/branches/tooling/www/analyzer/annotations.html
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/www/analyzer/annotations.html?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/www/analyzer/annotations.html (original)
+++ cfe/branches/tooling/www/analyzer/annotations.html Fri Jun 15 06:08:27 2012
@@ -541,7 +541,8 @@
<p>The analyzer knows about several well-known assertion handlers, but can
automatically infer if a function should be treated as an assertion handler if
it is annotated with the 'noreturn' attribute or the (Clang-specific)
-'analyzer_noreturn' attribute.</p>
+'analyzer_noreturn' attribute. Note that, currently, clang does not support
+these attributes on Objective-C methods and C++ methods.</p>
<h4 id="attr_noreturn">Attribute 'noreturn'</h4>
Modified: cfe/branches/tooling/www/analyzer/content.css
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/www/analyzer/content.css?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/www/analyzer/content.css (original)
+++ cfe/branches/tooling/www/analyzer/content.css Fri Jun 15 06:08:27 2012
@@ -15,6 +15,7 @@
h2 { color:#333333; padding-top:0.5em; }
h3 { padding-top: 0.5em; margin-bottom: -0.25em; color:#2d58b7 }
h4 { color:#2d58b7 }
+h4.faq { color:#2d58b7 }
li { padding-bottom: 0.5em }
ul { padding-left:1.5em; }
Modified: cfe/branches/tooling/www/analyzer/menu.html.incl
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/www/analyzer/menu.html.incl?rev=158515&r1=158514&r2=158515&view=diff
==============================================================================
--- cfe/branches/tooling/www/analyzer/menu.html.incl (original)
+++ cfe/branches/tooling/www/analyzer/menu.html.incl Fri Jun 15 06:08:27 2012
@@ -16,9 +16,10 @@
User Manual
<ul>
<li><a href="/installation.html">Obtaining the Analyzer</a></li>
- <li><a href="/scan-build.html">Command line usage</a></li>
+ <li><a href="/scan-build.html">Command Line Usage</a></li>
<li><a href="/xcode.html">Using within Xcode</a></li>
<li><a href="/available_checks.html">Available Checks</a></li>
+ <li><a href="/faq.html">FAQ</a></li>
<li><a href="/annotations.html">Source-level Annotations</a></li>
</ul>
</li>
@@ -26,7 +27,7 @@
Development
<ul>
<li><a href="/checker_dev_manual.html">Checker Developer Manual</a></li>
- <li><a href="/dev_cxx.html">Analysis support for C++</a></li>
+ <li><a href="/dev_cxx.html">Analysis Support for C++</a></li>
</ul>
</li>
<li>
More information about the llvm-branch-commits
mailing list