Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #20 from krasin/dcpu16

Update clang to the upstream tip
  • Loading branch information...
commit 4b960e0ff6c8f5c7cb84bcefd78ce6db5c272f77 2 parents 31e3eaa + 2ca3be4
Philipp Brüschweiler Blei authored
Showing with 9,935 additions and 6,493 deletions.
  1. +8 −0 CMakeLists.txt
  2. +153 −0 bindings/python/clang/cindex.py
  3. +17 −0 bindings/python/tests/cindex/INPUTS/compile_commands.json
  4. +81 −0 bindings/python/tests/cindex/test_cdb.py
  5. +8 −6 docs/AddressSanitizer.html
  6. +6 −0 docs/InternalsManual.html
  7. +49 −0 docs/ReleaseNotes.html
  8. +42 −0 docs/UsersManual.html
  9. +8 −0 docs/tools/clang.pod
  10. +146 −0 include/clang-c/CXCompilationDatabase.h
  11. +61 −0 include/clang-c/CXString.h
  12. +45 −56 include/clang-c/Index.h
  13. +45 −0 include/clang-c/Platform.h
  14. +9 −0 include/clang/AST/ASTContext.h
  15. +2 −2 include/clang/AST/ASTVector.h
  16. +49 −0 include/clang/AST/CommentBriefParser.h
  17. +345 −0 include/clang/AST/CommentLexer.h
  18. +10 −0 include/clang/AST/Decl.h
  19. +11 −2 include/clang/AST/DeclCXX.h
  20. +5 −3 include/clang/AST/DeclFriend.h
  21. +18 −28 include/clang/AST/Expr.h
  22. +1 −0  include/clang/AST/ExprCXX.h
  23. +1 −1  include/clang/AST/OperationKinds.h
  24. +31 −18 include/clang/AST/RawCommentList.h
  25. +1 −22 include/clang/AST/RecordLayout.h
  26. +2 −2 include/clang/AST/RecursiveASTVisitor.h
  27. +8 −14 include/clang/AST/Stmt.h
  28. +2 −1  include/clang/Analysis/Analyses/ThreadSafety.h
  29. +22 −21 include/clang/Basic/ABI.h
  30. +8 −6 include/clang/Basic/AddressSpaces.h
  31. +4 −4 include/clang/Basic/AllDiagnostics.h
  32. +5 −4 include/clang/Basic/AttrKinds.h
  33. +18 −17 include/clang/Basic/Builtins.h
  34. +125 −0 include/clang/Basic/BuiltinsMips.def
  35. +19 −0 include/clang/Basic/BuiltinsX86.def
  36. +19 −0 include/clang/Basic/ConvertUTF.h
  37. +188 −119 include/clang/Basic/Diagnostic.h
  38. +3 −1 include/clang/Basic/DiagnosticGroups.td
  39. +40 −39 include/clang/Basic/DiagnosticIDs.h
  40. +9 −3 include/clang/Basic/DiagnosticLexKinds.td
  41. +2 −2 include/clang/Basic/DiagnosticParseKinds.td
  42. +35 −18 include/clang/Basic/DiagnosticSemaKinds.td
  43. +5 −4 include/clang/Basic/ExceptionSpecificationType.h
  44. +4 −3 include/clang/Basic/ExpressionTraits.h
  45. +37 −25 include/clang/Basic/FileManager.h
  46. +4 −3 include/clang/Basic/FileSystemOptions.h
  47. +8 −6 include/clang/Basic/FileSystemStatCache.h
  48. +36 −29 include/clang/Basic/IdentifierTable.h
  49. +4 −3 include/clang/Basic/LLVM.h
  50. +8 −7 include/clang/Basic/Lambda.h
  51. +1 −1  include/clang/Basic/LangOptions.def
  52. +11 −9 include/clang/Basic/LangOptions.h
  53. +11 −10 include/clang/Basic/Linkage.h
  54. +4 −3 include/clang/Basic/MacroBuilder.h
  55. +6 −5 include/clang/Basic/Module.h
  56. +67 −37 include/clang/Basic/ObjCRuntime.h
  57. +4 −4 include/clang/Basic/OnDiskHashTable.h
  58. +5 −4 include/clang/Basic/OpenCL.h
  59. +6 −5 include/clang/Basic/OperatorKinds.h
  60. +20 −17 include/clang/Basic/PartialDiagnostic.h
  61. +8 −7 include/clang/Basic/PrettyStackTrace.h
  62. +32 −24 include/clang/Basic/SourceLocation.h
  63. +45 −36 include/clang/Basic/SourceManager.h
  64. +19 −17 include/clang/Basic/SourceManagerInternals.h
  65. +22 −23 include/clang/Basic/Specifiers.h
  66. +24 −8 include/clang/Basic/TargetBuiltins.h
  67. +130 −111 include/clang/Basic/TargetInfo.h
  68. +6 −1 include/clang/Basic/TargetOptions.h
  69. +4 −3 include/clang/Basic/TemplateKinds.h
  70. +6 −0 include/clang/Basic/TokenKinds.def
  71. +10 −11 include/clang/Basic/TokenKinds.h
  72. +8 −7 include/clang/Basic/TypeTraits.h
  73. +20 −18 include/clang/Basic/Version.h
  74. +26 −16 include/clang/Basic/VersionTuple.h
  75. +11 −8 include/clang/Basic/Visibility.h
  76. +25 −17 include/clang/Driver/Arg.h
  77. +2 −0  include/clang/Driver/CC1Options.td
  78. +2 −0  include/clang/Driver/Compilation.h
  79. +7 −0 include/clang/Driver/Options.td
  80. +0 −5 include/clang/Driver/ToolChain.h
  81. +6 −6 include/clang/Driver/Types.def
  82. +14 −2 include/clang/Frontend/ASTUnit.h
  83. +11 −0 include/clang/Frontend/CodeGenOptions.h
  84. +1 −2  include/clang/Frontend/CompilerInstance.h
  85. +3 −0  include/clang/Frontend/DiagnosticOptions.h
  86. +4 −10 include/clang/Frontend/FrontendOptions.h
  87. +5 −3 include/clang/Parse/Parser.h
  88. +42 −29 include/clang/Sema/CodeCompleteConsumer.h
  89. +37 −0 include/clang/Sema/CodeCompleteOptions.h
  90. +4 −4 include/clang/Sema/DelayedDiagnostic.h
  91. +1 −0  include/clang/Sema/Initialization.h
  92. +1 −1  include/clang/Sema/ScopeInfo.h
  93. +17 −5 include/clang/Sema/Sema.h
  94. +3 −1 include/clang/Serialization/ASTBitCodes.h
  95. +8 −0 include/clang/Serialization/ASTWriter.h
  96. +48 −17 include/clang/StaticAnalyzer/Core/Checker.h
  97. +35 −15 include/clang/StaticAnalyzer/Core/CheckerManager.h
  98. +498 −0 include/clang/StaticAnalyzer/Core/PathSensitive/Calls.h
  99. +4 −9 include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
  100. +13 −10 include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  101. +1 −0  include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  102. +0 −300 include/clang/StaticAnalyzer/Core/PathSensitive/ObjCMessage.h
  103. +3 −3 include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  104. +1 −0  include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  105. +2 −2 include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  106. +1 −1  include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
  107. +1 −0  lib/ARCMigrate/ObjCMT.cpp
  108. +1 −0  lib/ARCMigrate/TransAPIUses.cpp
  109. +1 −0  lib/ARCMigrate/TransARCAssign.cpp
  110. +1 −0  lib/ARCMigrate/TransAutoreleasePool.cpp
  111. +1 −0  lib/ARCMigrate/TransBlockObjCVariable.cpp
  112. +1 −0  lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
  113. +3 −2 lib/ARCMigrate/TransGCAttrs.cpp
  114. +1 −0  lib/ARCMigrate/TransGCCalls.cpp
  115. +3 −2 lib/ARCMigrate/TransRetainReleaseDealloc.cpp
  116. +3 −2 lib/ARCMigrate/TransUnbridgedCasts.cpp
  117. +1 −0  lib/ARCMigrate/TransUnusedInitDelegate.cpp
  118. +1 −0  lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp
  119. +1 −0  lib/ARCMigrate/TransformActions.cpp
  120. +5 −4 lib/ARCMigrate/Transforms.cpp
  121. +33 −10 lib/AST/ASTContext.cpp
  122. +933 −0 lib/AST/ASTDiagnostic.cpp
  123. +2 −0  lib/AST/CMakeLists.txt
  124. +1 −0  lib/AST/CXXInheritance.cpp
  125. +121 −0 lib/AST/CommentBriefParser.cpp
  126. +698 −0 lib/AST/CommentLexer.cpp
  127. +6 −0 lib/AST/Decl.cpp
  128. +9 −1 lib/AST/DeclCXX.cpp
  129. +6 −0 lib/AST/DeclFriend.cpp
  130. +51 −22 lib/AST/Expr.cpp
  131. +1 −0  lib/AST/ExprCXX.cpp
  132. +0 −4 lib/AST/ExprConstant.cpp
  133. +2 −0  lib/AST/LambdaMangleContext.cpp
  134. +7 −0 lib/AST/MicrosoftMangle.cpp
  135. +34 −12 lib/AST/RawCommentList.cpp
  136. +1 −1  lib/AST/RecordLayout.cpp
  137. +1 −0  lib/AST/RecordLayoutBuilder.cpp
  138. +16 −0 lib/AST/Stmt.cpp
  139. +2 −1  lib/AST/StmtDumper.cpp
  140. +7 −1 lib/AST/StmtPrinter.cpp
  141. +1 −0  lib/AST/TypeLoc.cpp
  142. +25 −5 lib/AST/TypePrinter.cpp
  143. +1 −0  lib/AST/VTTBuilder.cpp
  144. +8 −7 lib/AST/VTableBuilder.cpp
  145. +1 −0  lib/Analysis/AnalysisDeclContext.cpp
  146. +1 −0  lib/Analysis/CFG.cpp
  147. +5 −0 lib/Analysis/LiveVariables.cpp
  148. +1 −0  lib/Analysis/PseudoConstantAnalysis.cpp
  149. +135 −49 lib/Analysis/ThreadSafety.cpp
  150. +18 −0 lib/Analysis/UninitializedValues.cpp
  151. +1 −0  lib/Basic/CMakeLists.txt
  152. +54 −0 lib/Basic/ConvertUTFWrapper.cpp
  153. +82 −1 lib/Basic/Diagnostic.cpp
  154. +17 −0 lib/Basic/FileManager.cpp
  155. +10 −7 lib/Basic/ObjCRuntime.cpp
  156. +0 −2  lib/Basic/SourceManager.cpp
  157. +59 −10 lib/Basic/Targets.cpp
  158. +1 −1  lib/CodeGen/CGBuilder.h
  159. +0 −2,584 lib/CodeGen/CGBuiltin.cpp
  160. +1 −1  lib/CodeGen/CGCXX.cpp
  161. +1 −1  lib/CodeGen/CGCXXABI.cpp
  162. +2 −2 lib/CodeGen/CGDebugInfo.cpp
  163. +3 −2 lib/CodeGen/CGDebugInfo.h
  164. +6 −12 lib/CodeGen/CGDecl.cpp
  165. +6 −5 lib/CodeGen/CGException.cpp
  166. +30 −62 lib/CodeGen/CGExpr.cpp
  167. +166 −84 lib/CodeGen/CGExprAgg.cpp
  168. +53 −18 lib/CodeGen/CGExprCXX.cpp
  169. +2 −1  lib/CodeGen/CGExprConstant.cpp
  170. +2 −3 lib/CodeGen/CGExprScalar.cpp
  171. +2 −2 lib/CodeGen/CGObjCGNU.cpp
  172. +2 −2 lib/CodeGen/CGObjCMac.cpp
  173. +4 −1 lib/CodeGen/CGObjCRuntime.cpp
  174. +1 −6 lib/CodeGen/CGRecordLayout.h
  175. +2 −0  lib/CodeGen/CGRecordLayoutBuilder.cpp
  176. +5 −4 lib/CodeGen/CGValue.h
  177. +5 −8 lib/CodeGen/CodeGenFunction.h
  178. +45 −10 lib/CodeGen/CodeGenModule.cpp
  179. +4 −9 lib/CodeGen/CodeGenModule.h
  180. +34 −34 lib/CodeGen/TargetInfo.cpp
  181. +5 −2 lib/Driver/Driver.cpp
  182. +1 −1  lib/Driver/ToolChain.cpp
  183. +0 −29 lib/Driver/ToolChains.h
  184. +73 −36 lib/Driver/Tools.cpp
  185. +1 −0  lib/Edit/Commit.cpp
  186. +1 −0  lib/Edit/RewriteObjCFoundationAPI.cpp
  187. +33 −18 lib/Frontend/ASTUnit.cpp
  188. +3 −8 lib/Frontend/CompilerInstance.cpp
  189. +57 −13 lib/Frontend/CompilerInvocation.cpp
  190. +43 −9 lib/Frontend/TextDiagnostic.cpp
  191. +5 −1 lib/Frontend/Warnings.cpp
  192. +240 −0 lib/Headers/avx2intrin.h
  193. +3 −3 lib/Headers/bmiintrin.h
  194. +7 −0 lib/Headers/stddef.h
  195. +3 −3 lib/Lex/Lexer.cpp
  196. +1 −36 lib/Lex/LiteralSupport.cpp
  197. +4 −8 lib/Lex/PPDirectives.cpp
  198. +1 −0  lib/Lex/PPMacroExpansion.cpp
  199. +4 −0 lib/Lex/Pragma.cpp
  200. +10 −0 lib/Lex/Preprocessor.cpp
  201. +1 −0  lib/Parse/ParseAST.cpp
  202. +1 −0  lib/Parse/ParseCXXInlineMethods.cpp
  203. +166 −152 lib/Parse/ParseDecl.cpp
  204. +5 −3 lib/Parse/ParseDeclCXX.cpp
  205. +17 −9 lib/Parse/ParseExpr.cpp
  206. +41 −22 lib/Parse/ParseObjc.cpp
  207. +8 −8 lib/Parse/ParseStmt.cpp
  208. +1 −0  lib/Parse/ParseTentative.cpp
  209. +5 −2 lib/Parse/Parser.cpp
  210. +116 −40 lib/Rewrite/RewriteModernObjC.cpp
  211. +45 −25 lib/Rewrite/RewriteObjC.cpp
  212. +3 −0  lib/Sema/AnalysisBasedWarnings.cpp
  213. +1 −0  lib/Sema/AttributeList.cpp
  214. +14 −5 lib/Sema/CodeCompleteConsumer.cpp
  215. +13 −5 lib/Sema/Sema.cpp
  216. +4 −2 lib/Sema/SemaAccess.cpp
  217. +16 −2 lib/Sema/SemaChecking.cpp
  218. +27 −4 lib/Sema/SemaCodeComplete.cpp
  219. +26 −1 lib/Sema/SemaDecl.cpp
  220. +7 −6 lib/Sema/SemaDeclCXX.cpp
  221. +29 −5 lib/Sema/SemaDeclObjC.cpp
  222. +44 −11 lib/Sema/SemaExpr.cpp
  223. +33 −2 lib/Sema/SemaExprCXX.cpp
  224. +4 −2 lib/Sema/SemaExprObjC.cpp
  225. +1 −0  lib/Sema/SemaFixItUtils.cpp
  226. +138 −3 lib/Sema/SemaLambda.cpp
  227. +6 −0 lib/Sema/SemaLookup.cpp
  228. +3 −4 lib/Sema/SemaObjCProperty.cpp
  229. +50 −53 lib/Sema/SemaStmt.cpp
  230. +10 −13 lib/Sema/SemaTemplateInstantiate.cpp
  231. +107 −107 lib/Sema/SemaType.cpp
  232. +7 −18 lib/Sema/TreeTransform.h
  233. +2 −0  lib/Serialization/ASTCommon.h
  234. +5 −0 lib/Serialization/ASTReader.cpp
  235. +1 −0  lib/Serialization/ASTReaderStmt.cpp
  236. +24 −2 lib/Serialization/ASTWriter.cpp
  237. +1 −0  lib/Serialization/ASTWriterStmt.cpp
  238. +22 −25 lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp
  239. +26 −27 lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
  240. +1 −0  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  241. +2 −2 lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  242. +105 −99 lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
  243. +36 −6 lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
  244. +4 −0 lib/StaticAnalyzer/Checkers/Checkers.td
  245. +114 −143 lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  246. +7 −16 lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp
  247. +3 −3 lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
  248. +0 −1  lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
  249. +31 −45 lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
  250. +227 −234 lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  251. +57 −0 lib/StaticAnalyzer/Checkers/TraversalChecker.cpp
  252. +1 −0  lib/StaticAnalyzer/Core/BasicValueFactory.cpp
  253. +1 −1  lib/StaticAnalyzer/Core/CMakeLists.txt
  254. +401 −0 lib/StaticAnalyzer/Core/Calls.cpp
  255. +68 −25 lib/StaticAnalyzer/Core/CheckerManager.cpp
  256. +1 −1  lib/StaticAnalyzer/Core/CoreEngine.cpp
  257. +3 −3 lib/StaticAnalyzer/Core/ExplodedGraph.cpp
  258. +18 −20 lib/StaticAnalyzer/Core/ExprEngine.cpp
  259. +39 −242 lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  260. +158 −273 lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  261. +32 −27 lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
  262. +0 −175 lib/StaticAnalyzer/Core/ObjCMessage.cpp
  263. +2 −2 lib/StaticAnalyzer/Core/ProgramState.cpp
  264. +3 −3 lib/StaticAnalyzer/Core/RegionStore.cpp
  265. +13 −7 lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  266. +1 −1  test/ARCMT/checking.m
  267. +13 −0 test/Analysis/blocks-no-inline.c
  268. +2 −3 test/Analysis/delegates.m
  269. +12 −0 test/Analysis/malloc.c
  270. +1 −1  test/Analysis/misc-ps-region-store.m
  271. +10 −11 test/Analysis/new.cpp
  272. +2 −2 test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
  273. +23 −0 test/Analysis/nonnull.m
  274. +18 −1 test/Analysis/operator-calls.cpp
  275. +213 −0 test/Analysis/traversal-algorithm.mm
  276. +74 −98 test/CMakeLists.txt
  277. +3 −3 test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp
  278. +33 −0 test/CodeCompletion/documentation.cpp
  279. +1 −1  test/CodeGen/2010-02-10-PointerName.c
  280. +156 −0 test/CodeGen/avx2-builtins.c
  281. +12 −0 test/CodeGen/block-3.c
  282. +60 −11 test/CodeGen/block-byref-aggr.c
  283. +6 −6 test/CodeGen/bmi-builtins.c
  284. +40 −0 test/CodeGen/branch-target-layout.c
  285. +227 −0 test/CodeGen/builtins-mips.c
  286. +28 −0 test/CodeGen/mips-vector-arg.c
  287. +10 −0 test/CodeGen/mips-vector-return.c
  288. +18 −0 test/CodeGen/packed-nest-unpacked.c
  289. +28 −0 test/CodeGen/tls-model.c
  290. +7 −1 test/CodeGen/varargs.c
  291. +80 −1 test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
  292. +30 −0 test/CodeGenCXX/devirtualize-virtual-function-calls.cpp
  293. +14 −0 test/CodeGenCXX/inline-functions.cpp
  294. +100 −2 test/CodeGenCXX/mangle-ms-back-references.cpp
  295. +14 −2 test/CodeGenCXX/mangle-ms.cpp
  296. +1 −1  test/CodeGenObjC/bitfield-gnu.m
  297. +1 −1  test/CodeGenObjC/bitfield_encoding.m
  298. +2 −2 test/CodeGenObjC/constant-strings.m
  299. +19 −0 test/CodeGenObjC/encode-test-6.m
  300. +1 −1  test/CodeGenObjC/gnu-exceptions.m
Sorry, we could not display the entire diff because too many files (370) changed.
8 CMakeLists.txt
View
@@ -53,6 +53,14 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
set(LLVM_TABLEGEN_EXE "${PATH_TO_LLVM_BUILD}/bin/Debug/llvm-tblgen${CMAKE_EXECUTABLE_SUFFIX}")
endif()
+ # Define the default arguments to use with 'lit', and an option for the user
+ # to override.
+ set(LIT_ARGS_DEFAULT "-sv")
+ if (MSVC OR XCODE)
+ set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
+ endif()
+ set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
+
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
153 bindings/python/clang/cindex.py
View
@@ -2096,6 +2096,120 @@ def is_input_file(self):
"""True if the included file is the input file."""
return self.depth == 0
+class CompilationDatabaseError(Exception):
+ """Represents an error that occurred when working with a CompilationDatabase
+
+ Each error is associated to an enumerated value, accessible under
+ e.cdb_error. Consumers can compare the value with one of the ERROR_
+ constants in this class.
+ """
+
+ # An unknown error occured
+ ERROR_UNKNOWN = 0
+
+ # The database could not be loaded
+ ERROR_CANNOTLOADDATABASE = 1
+
+ def __init__(self, enumeration, message):
+ assert isinstance(enumeration, int)
+
+ if enumeration > 1:
+ raise Exception("Encountered undefined CompilationDatabase error "
+ "constant: %d. Please file a bug to have this "
+ "value supported." % enumeration)
+
+ self.cdb_error = enumeration
+ Exception.__init__(self, 'Error %d: %s' % (enumeration, message))
+
+class CompileCommand(object):
+ """Represents the compile command used to build a file"""
+ def __init__(self, cmd, ccmds):
+ self.cmd = cmd
+ # Keep a reference to the originating CompileCommands
+ # to prevent garbage collection
+ self.ccmds = ccmds
+
+ @property
+ def directory(self):
+ """Get the working directory for this CompileCommand"""
+ return CompileCommand_getDirectory(self.cmd).spelling
+
+ @property
+ def arguments(self):
+ """
+ Get an iterable object providing each argument in the
+ command line for the compiler invocation as a _CXString.
+
+ Invariants :
+ - the first argument is the compiler executable
+ - the last argument is the file being compiled
+ """
+ length = CompileCommand_getNumArgs(self.cmd)
+ for i in xrange(length):
+ yield CompileCommand_getArg(self.cmd, i)
+
+class CompileCommands(object):
+ """
+ CompileCommands is an iterable object containing all CompileCommand
+ that can be used for building a specific file.
+ """
+ def __init__(self, ccmds):
+ self.ccmds = ccmds
+
+ def __del__(self):
+ CompileCommands_dispose(self.ccmds)
+
+ def __len__(self):
+ return int(CompileCommands_getSize(self.ccmds))
+
+ def __getitem__(self, i):
+ cc = CompileCommands_getCommand(self.ccmds, i)
+ if cc is None:
+ raise IndexError
+ return CompileCommand(cc, self)
+
+ @staticmethod
+ def from_result(res, fn, args):
+ if not res:
+ return None
+ return CompileCommands(res)
+
+class CompilationDatabase(ClangObject):
+ """
+ The CompilationDatabase is a wrapper class around
+ clang::tooling::CompilationDatabase
+
+ It enables querying how a specific source file can be built.
+ """
+
+ def __del__(self):
+ CompilationDatabase_dispose(self)
+
+ @staticmethod
+ def from_result(res, fn, args):
+ if not res:
+ raise CompilationDatabaseError(0,
+ "CompilationDatabase loading failed")
+ return CompilationDatabase(res)
+
+ @staticmethod
+ def fromDirectory(buildDir):
+ """Builds a CompilationDatabase from the database found in buildDir"""
+ errorCode = c_uint()
+ try:
+ cdb = CompilationDatabase_fromDirectory(buildDir, byref(errorCode))
+ except CompilationDatabaseError as e:
+ raise CompilationDatabaseError(int(errorCode.value),
+ "CompilationDatabase loading failed")
+ return cdb
+
+ def getCompileCommands(self, filename):
+ """
+ Get an iterable object providing all the CompileCommands available to
+ build filename. Returns None if filename is not found in the database.
+ """
+ return CompilationDatabase_getCompileCommands(self, filename)
+
# Additional Functions and Types
# String Functions
@@ -2463,9 +2577,48 @@ def is_input_file(self):
_clang_getCompletionPriority.argtypes = [c_void_p]
_clang_getCompletionPriority.restype = c_int
+# Compilation Database
+CompilationDatabase_fromDirectory = lib.clang_CompilationDatabase_fromDirectory
+CompilationDatabase_fromDirectory.argtypes = [c_char_p, POINTER(c_uint)]
+CompilationDatabase_fromDirectory.restype = c_object_p
+CompilationDatabase_fromDirectory.errcheck = CompilationDatabase.from_result
+
+CompilationDatabase_dispose = lib.clang_CompilationDatabase_dispose
+CompilationDatabase_dispose.argtypes = [c_object_p]
+
+CompilationDatabase_getCompileCommands = lib.clang_CompilationDatabase_getCompileCommands
+CompilationDatabase_getCompileCommands.argtypes = [c_object_p, c_char_p]
+CompilationDatabase_getCompileCommands.restype = c_object_p
+CompilationDatabase_getCompileCommands.errcheck = CompileCommands.from_result
+
+CompileCommands_dispose = lib.clang_CompileCommands_dispose
+CompileCommands_dispose.argtypes = [c_object_p]
+
+CompileCommands_getSize = lib.clang_CompileCommands_getSize
+CompileCommands_getSize.argtypes = [c_object_p]
+CompileCommands_getSize.restype = c_uint
+
+CompileCommands_getCommand = lib.clang_CompileCommands_getCommand
+CompileCommands_getCommand.argtypes = [c_object_p, c_uint]
+CompileCommands_getCommand.restype = c_object_p
+
+CompileCommand_getDirectory = lib.clang_CompileCommand_getDirectory
+CompileCommand_getDirectory.argtypes = [c_object_p]
+CompileCommand_getDirectory.restype = _CXString
+
+CompileCommand_getNumArgs = lib.clang_CompileCommand_getNumArgs
+CompileCommand_getNumArgs.argtypes = [c_object_p]
+CompileCommand_getNumArgs.restype = c_uint
+
+CompileCommand_getArg = lib.clang_CompileCommand_getArg
+CompileCommand_getArg.argtypes = [c_object_p, c_uint]
+CompileCommand_getArg.restype = _CXString
__all__ = [
'CodeCompletionResults',
+ 'CompilationDatabase',
+ 'CompileCommands',
+ 'CompileCommand',
'CursorKind',
'Cursor',
'Diagnostic',
17 bindings/python/tests/cindex/INPUTS/compile_commands.json
View
@@ -0,0 +1,17 @@
+[
+{
+ "directory": "/home/john.doe/MyProject",
+ "command": "clang++ -o project.o -c /home/john.doe/MyProject/project.cpp",
+ "file": "/home/john.doe/MyProject/project.cpp"
+},
+{
+ "directory": "/home/john.doe/MyProjectA",
+ "command": "clang++ -o project2.o -c /home/john.doe/MyProject/project2.cpp",
+ "file": "/home/john.doe/MyProject/project2.cpp"
+},
+{
+ "directory": "/home/john.doe/MyProjectB",
+ "command": "clang++ -DFEATURE=1 -o project2-feature.o -c /home/john.doe/MyProject/project2.cpp",
+ "file": "/home/john.doe/MyProject/project2.cpp"
+}
+]
81 bindings/python/tests/cindex/test_cdb.py
View
@@ -0,0 +1,81 @@
+from clang.cindex import CompilationDatabase
+from clang.cindex import CompilationDatabaseError
+from clang.cindex import CompileCommands
+from clang.cindex import CompileCommand
+import os
+import gc
+
+kInputsDir = os.path.join(os.path.dirname(__file__), 'INPUTS')
+
+def test_create_fail():
+ """Check we fail loading a database with an assertion"""
+ path = os.path.dirname(__file__)
+ try:
+ cdb = CompilationDatabase.fromDirectory(path)
+ except CompilationDatabaseError as e:
+ assert e.cdb_error == CompilationDatabaseError.ERROR_CANNOTLOADDATABASE
+ else:
+ assert False
+
+def test_create():
+ """Check we can load a compilation database"""
+ cdb = CompilationDatabase.fromDirectory(kInputsDir)
+
+def test_lookup_fail():
+ """Check file lookup failure"""
+ cdb = CompilationDatabase.fromDirectory(kInputsDir)
+ assert cdb.getCompileCommands('file_do_not_exist.cpp') == None
+
+def test_lookup_succeed():
+ """Check we get some results if the file exists in the db"""
+ cdb = CompilationDatabase.fromDirectory(kInputsDir)
+ cmds = cdb.getCompileCommands('/home/john.doe/MyProject/project.cpp')
+ assert len(cmds) != 0
+
+def test_1_compilecommand():
+ """Check file with single compile command"""
+ cdb = CompilationDatabase.fromDirectory(kInputsDir)
+ cmds = cdb.getCompileCommands('/home/john.doe/MyProject/project.cpp')
+ assert len(cmds) == 1
+ assert cmds[0].directory == '/home/john.doe/MyProject'
+ expected = [ 'clang++', '-o', 'project.o', '-c',
+ '/home/john.doe/MyProject/project.cpp']
+ for arg, exp in zip(cmds[0].arguments, expected):
+ assert arg.spelling == exp
+
+def test_2_compilecommand():
+ """Check file with 2 compile commands"""
+ cdb = CompilationDatabase.fromDirectory(kInputsDir)
+ cmds = cdb.getCompileCommands('/home/john.doe/MyProject/project2.cpp')
+ assert len(cmds) == 2
+ expected = [
+ { 'wd': '/home/john.doe/MyProjectA',
+ 'line': ['clang++', '-o', 'project2.o', '-c',
+ '/home/john.doe/MyProject/project2.cpp']},
+ { 'wd': '/home/john.doe/MyProjectB',
+ 'line': ['clang++', '-DFEATURE=1', '-o', 'project2-feature.o', '-c',
+ '/home/john.doe/MyProject/project2.cpp']}
+ ]
+ for i in range(len(cmds)):
+ assert cmds[i].directory == expected[i]['wd']
+ for arg, exp in zip(cmds[i].arguments, expected[i]['line']):
+ assert arg.spelling == exp
+
+def test_compilationDB_references():
+ """Ensure CompilationsCommands are independent of the database"""
+ cdb = CompilationDatabase.fromDirectory(kInputsDir)
+ cmds = cdb.getCompileCommands('/home/john.doe/MyProject/project.cpp')
+ del cdb
+ gc.collect()
+ workingdir = cmds[0].directory
+
+def test_compilationCommands_references():
+ """Ensure CompilationsCommand keeps a reference to CompilationCommands"""
+ cdb = CompilationDatabase.fromDirectory(kInputsDir)
+ cmds = cdb.getCompileCommands('/home/john.doe/MyProject/project.cpp')
+ del cdb
+ cmd0 = cmds[0]
+ del cmds
+ gc.collect()
+ workingdir = cmd0.directory
+
14 docs/AddressSanitizer.html
View
@@ -99,10 +99,10 @@ <h3 id="has_feature">__has_feature(address_sanitizer)</h3>
<a href="LanguageExtensions.html#__has_feature_extension">__has_feature</a>
can be used for this purpose.
<pre>
-#if defined(__has_feature) &amp;&amp; __has_feature(address_sanitizer)
- code that runs only under AddressSanitizer
-#else
- code that does not run under AddressSanitizer
+#if defined(__has_feature)
+# if __has_feature(address_sanitizer)
+ code that builds only under AddressSanitizer
+# endif
#endif
</pre>
@@ -112,14 +112,16 @@ <h3 id="no_address_safety_analysis">__attribute__((no_address_safety_analysis))<
<a href="LanguageExtensions.html#address_sanitizer">
<tt>no_address_safety_analysis</tt></a>
to disable instrumentation of a particular function.
+This attribute may not be supported by other compilers, so we suggest to
+use it together with <tt>__has_feature(address_sanitizer)</tt>.
Note: currently, this attribute will be lost if the function is inlined.
<h2 id="platforms">Supported Platforms</h2>
AddressSanitizer is supported on
<ul><li>Linux x86_64 (tested on Ubuntu 10.04).
-<li>MacOS 10.6 i386/x86_64.
+<li>MacOS 10.6 and 10.7 (i386/x86_64).
</ul>
-Support for Linux i386/ARM and MacOS 10.7 is in progress
+Support for Linux i386/ARM is in progress
(it may work, but is not guaranteed too).
6 docs/InternalsManual.html
View
@@ -357,6 +357,12 @@ <h3 id="Diagnostics">The Diagnostics Subsystem</h3>
<tr><td>Example:</td><td><tt>"candidate found by name lookup is %q0"</tt></td></tr>
<tr><td>Class:</td><td>NamedDecl*</td></tr>
<tr><td>Description</td><td><p>This formatter indicates that the fully-qualified name of the declaration should be printed, e.g., "std::vector" rather than "vector".</p></td></tr>
+
+<tr><td colspan="2"><b>"diff" format</b></td></tr>
+<tr><td>Example:</td><td><tt>"no known conversion %diff{from | to | }1,2"</tt></td></tr>
+<tr><td>Class:</td><td>QualType</td></tr>
+<tr><td>Description</td><td><p>This formatter takes two QualTypes and attempts to print a template difference between the two. If tree printing is off, the text inside the the braces before the pipe is printed, with the formatted text replacing the $. If tree printing is on, the text after the pipe is printed and a type tree is printed after the diagnostic message.
+</p></td></tr>
</table>
49 docs/ReleaseNotes.html
View
@@ -121,6 +121,55 @@ <h4 id="diagnostics">Improvements to Clang's diagnostics</h4>
This functionality can be enabled or disabled separately from
<tt>-Wuninitialized</tt> with the <tt>-Wsometimes-uninitialized</tt> warning
flag.</li>
+
+ <li>Template type diffing improves the display of diagnostics with templated
+ types in them.
+
+<pre>
+int f(vector&lt;map&lt;int, double&gt;&gt;);
+int x = f(vector&lt;map&lt;int, float&gt;&gt;());
+</pre>
+ The error message is the same, but the note is different based on the options selected.
+<pre>
+<b>template-diff.cpp:5:9: <span class="error">error:</span> no matching function for call to 'f'</b>
+int x = f(vector&lt;map&lt;int, float&gt;&gt;());
+ <span class="caret">^</span>
+</pre>
+ Templated type diffing with type elision (default):
+<pre>
+<b>template-diff.cpp:4:5: <span class="note">note:</span></b> candidate function not viable: no known conversion from 'vector&lt;map&lt;[...], <span class="template-highlight">float</span>&gt;&gt;' to 'vector&lt;map&lt;[...], <span class="template-highlight">double</span>&gt;&gt;' for 1st argument;
+int f(vector&lt;map&lt;int, double&gt;&gt;);
+ <span class="caret">^</span>
+</pre>
+ Templated type diffing without type elision (-fno-elide-type):
+<pre>
+<b>template-diff.cpp:4:5: <span class="note">note:</span></b> candidate function not viable: no known conversion from 'vector&lt;map&lt;int, <span class="template-highlight">float</span>&gt;&gt;' to 'vector&lt;map&lt;int, <span class="template-highlight">double</span>&gt;&gt;' for 1st argument;
+int f(vector&lt;map&lt;int, double&gt;&gt;);
+ <span class="caret">^</span>
+</pre>
+ Templated tree printing with type elision (-fdiagnostics-show-template-tree):
+<pre>
+<b>template-diff.cpp:4:5: <span class="note">note:</span></b> candidate function not viable: no known conversion for 1st argument;
+ vector&lt;
+ map&lt;
+ [...],
+ [<span class="template-highlight">float</span> != <span class="template-highlight">double</span>]&gt;&gt;
+int f(vector&lt;map&lt;int, double&gt;&gt;);
+ <span class="caret">^</span>
+</pre>
+ Templated tree printing without type elision (-fdiagnostics-show-template-tree -fno-elide-type):
+<pre>
+<b>template-diff.cpp:4:5: <span class="note">note:</span></b> candidate function not viable: no known conversion for 1st argument;
+ vector&lt;
+ map&lt;
+ int,
+ [<span class="template-highlight">float</span> != <span class="template-highlight">double</span>]&gt;&gt;
+int f(vector&lt;map&lt;int, double&gt;&gt;);
+ <span class="caret">^</span>
+</pre>
+
+ </li>
+
</ul>
<h4 id="tlsmodel">Support for <code>tls_model</code> attribute</h4>
42 docs/UsersManual.html
View
@@ -417,6 +417,48 @@ <h4 id="cl_diag_formatting">Formatting of Diagnostics</h4>
&quot;\xxx&quot;).</p>
</dd>
+<dt id="opt_fno-elide-type">
+<b>-fno-elide-type</b>:
+Turns off elision in template type printing.</td>
+<dd><p>The default for template type printing is to elide as many template
+arguments as possible, removing those which are the same in both template types,
+leaving only the differences. Adding this flag will print all the template
+arguments. If supported by the terminal, highlighting will still appear on
+differing arguments.</p>
+
+Default:
+<pre>
+t.cc:4:5: <span class="note">note</span>: candidate function not viable: no known conversion from 'vector&lt;map&lt;[...], map&lt;<span class="template-highlight">float</span>, [...]&gt;&gt;&gt;' to 'vector&lt;map&lt;[...], map&lt;<span class="template-highlight">double</span>, [...]&gt;&gt;&gt;' for 1st argument;
+</pre>
+-fno-elide-type:
+<pre>
+t.cc:4:5: <span class="note">note</span>: candidate function not viable: no known conversion from 'vector&lt;map&lt;int, map&lt;<span class="template-highlight">float</span>, int&gt;&gt;&gt;' to 'vector&lt;map&lt;int, map&lt;<span class="template-highlight">double</span>, int&gt;&gt;&gt;' for 1st argument;
+</pre>
+</dd>
+
+<dt id="opt_fdiagnostics-show-template-tree">
+<b>-fdiagnostics-show-template-tree</b>:
+Template type diffing prints a text tree.</td>
+<dd><p>For diffing large templated types, this option will cause Clang to
+display the templates as an indented text tree, one argument per line, with
+differences marked inline. This is compatible with -fno-elide-type.</p>
+
+Default:
+<pre>
+t.cc:4:5: <span class="note">note</span>: candidate function not viable: no known conversion from 'vector&lt;map&lt;[...], map&lt;<span class="template-highlight">float</span>, [...]&gt;&gt;&gt;' to 'vector&lt;map&lt;[...], map&lt;<span class="template-highlight">double</span>, [...]&gt;&gt;&gt;' for 1st argument;
+</pre>
+-fdiagnostics-show-template-tree
+<pre>
+t.cc:4:5: <span class="note">note</span>: candidate function not viable: no known conversion for 1st argument;
+ vector&lt;
+ map&lt;
+ [...],
+ map&lt;
+ [<span class="template-highlight">float</span> != <span class="template-highlight">float</span>],
+ [...]&gt;&gt;&gt;
+</pre>
+</dd>
+
</dl>
8 docs/tools/clang.pod
View
@@ -303,6 +303,14 @@ This flag sets the default visibility level.
This flag specifies that variables without initializers get common linkage. It
can be disabled with B<-fno-common>.
+=item B<-ftls-model>
+
+Set the default thread-local storage (TLS) model to use for thread-local
+variables. Valid values are: "global-dynamic", "local-dynamic", "initial-exec"
+and "local-exec". The default is "global-dynamic". The default model can be
+overridden with the tls_model attribute. The compiler will try to choose a more
+efficient model if possible.
+
=item B<-flto> B<-emit-llvm>
Generate output files in LLVM formats, suitable for link time optimization. When
146 include/clang-c/CXCompilationDatabase.h
View
@@ -0,0 +1,146 @@
+/*===-- clang-c/CXCompilationDatabase.h - Compilation database ---*- C -*-===*\
+|* *|
+|* The LLVM Compiler Infrastructure *|
+|* *|
+|* This file is distributed under the University of Illinois Open Source *|
+|* License. See LICENSE.TXT for details. *|
+|* *|
+|*===----------------------------------------------------------------------===*|
+|* *|
+|* This header provides a public inferface to use CompilationDatabase without *|
+|* the full Clang C++ API. *|
+|* *|
+\*===----------------------------------------------------------------------===*/
+
+#ifndef CLANG_CXCOMPILATIONDATABASE_H
+#define CLANG_CXCOMPILATIONDATABASE_H
+
+#include "clang-c/Platform.h"
+#include "clang-c/CXString.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** \defgroup COMPILATIONDB CompilationDatabase functions
+ * \ingroup CINDEX
+ *
+ * @{
+ */
+
+/**
+ * A compilation database holds all information used to compile files in a
+ * project. For each file in the database, it can be queried for the working
+ * directory or the command line used for the compiler invocation.
+ *
+ * Must be freed by \c clang_CompilationDatabase_dispose
+ */
+typedef void * CXCompilationDatabase;
+
+/**
+ * \brief Contains the results of a search in the compilation database
+ *
+ * When searching for the compile command for a file, the compilation db can
+ * return several commands, as the file may have been compiled with
+ * different options in different places of the project. This choice of compile
+ * commands is wrapped in this opaque data structure. It must be freed by
+ * \c clang_CompileCommands_dispose.
+ */
+typedef void * CXCompileCommands;
+
+/**
+ * \brief Represents the command line invocation to compile a specific file.
+ */
+typedef void * CXCompileCommand;
+
+/**
+ * \brief Error codes for Compilation Database
+ */
+typedef enum {
+ /*
+ * \brief No error occured
+ */
+ CXCompilationDatabase_NoError = 0,
+
+ /*
+ * \brief Database can not be loaded
+ */
+ CXCompilationDatabase_CanNotLoadDatabase = 1
+
+} CXCompilationDatabase_Error;
+
+/**
+ * \brief Creates a compilation database from the database found in directory
+ * buildDir. For example, CMake can output a compile_commands.json which can
+ * be used to build the database.
+ *
+ * It must be freed by \c clang_CompilationDatabase_dispose.
+ */
+CINDEX_LINKAGE CXCompilationDatabase
+clang_CompilationDatabase_fromDirectory(const char *BuildDir,
+ CXCompilationDatabase_Error *ErrorCode);
+
+/**
+ * \brief Free the given compilation database
+ */
+CINDEX_LINKAGE void
+clang_CompilationDatabase_dispose(CXCompilationDatabase);
+
+/**
+ * \brief Find the compile commands used for a file. The compile commands
+ * must be freed by \c clang_CompileCommands_dispose.
+ */
+CINDEX_LINKAGE CXCompileCommands
+clang_CompilationDatabase_getCompileCommands(CXCompilationDatabase,
+ const char *CompleteFileName);
+
+/**
+ * \brief Free the given CompileCommands
+ */
+CINDEX_LINKAGE void clang_CompileCommands_dispose(CXCompileCommands);
+
+/**
+ * \brief Get the number of CompileCommand we have for a file
+ */
+CINDEX_LINKAGE unsigned
+clang_CompileCommands_getSize(CXCompileCommands);
+
+/**
+ * \brief Get the I'th CompileCommand for a file
+ *
+ * Note : 0 <= i < clang_CompileCommands_getSize(CXCompileCommands)
+ */
+CINDEX_LINKAGE CXCompileCommand
+clang_CompileCommands_getCommand(CXCompileCommands, unsigned I);
+
+/**
+ * \brief Get the working directory where the CompileCommand was executed from
+ */
+CINDEX_LINKAGE CXString
+clang_CompileCommand_getDirectory(CXCompileCommand);
+
+/**
+ * \brief Get the number of arguments in the compiler invocation.
+ *
+ */
+CINDEX_LINKAGE unsigned
+clang_CompileCommand_getNumArgs(CXCompileCommand);
+
+/**
+ * \brief Get the I'th argument value in the compiler invocations
+ *
+ * Invariant :
+ * - argument 0 is the compiler executable
+ */
+CINDEX_LINKAGE CXString
+clang_CompileCommand_getArg(CXCompileCommand, unsigned I);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
61 include/clang-c/CXString.h
View
@@ -0,0 +1,61 @@
+/*===-- clang-c/CXString.h - C Index strings --------------------*- C -*-===*\
+|* *|
+|* The LLVM Compiler Infrastructure *|
+|* *|
+|* This file is distributed under the University of Illinois Open Source *|
+|* License. See LICENSE.TXT for details. *|
+|* *|
+|*===----------------------------------------------------------------------===*|
+|* *|
+|* This header provides the interface to C Index strings. *|
+|* *|
+\*===----------------------------------------------------------------------===*/
+
+#ifndef CLANG_CXSTRING_H
+#define CLANG_CXSTRING_H
+
+#include "clang-c/Platform.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \defgroup CINDEX_STRING String manipulation routines
+ * \ingroup CINDEX
+ *
+ * @{
+ */
+
+/**
+ * \brief A character string.
+ *
+ * The \c CXString type is used to return strings from the interface when
+ * the ownership of that string might different from one call to the next.
+ * Use \c clang_getCString() to retrieve the string data and, once finished
+ * with the string data, call \c clang_disposeString() to free the string.
+ */
+typedef struct {
+ void *data;
+ unsigned private_flags;
+} CXString;
+
+/**
+ * \brief Retrieve the character data associated with the given string.
+ */
+CINDEX_LINKAGE const char *clang_getCString(CXString string);
+
+/**
+ * \brief Free the given string,
+ */
+CINDEX_LINKAGE void clang_disposeString(CXString string);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
101 include/clang-c/Index.h
View
@@ -20,31 +20,13 @@
#include <time.h>
#include <stdio.h>
+#include "clang-c/Platform.h"
+#include "clang-c/CXString.h"
+
#ifdef __cplusplus
extern "C" {
#endif
-/* MSVC DLL import/export. */
-#ifdef _MSC_VER
- #ifdef _CINDEX_LIB_
- #define CINDEX_LINKAGE __declspec(dllexport)
- #else
- #define CINDEX_LINKAGE __declspec(dllimport)
- #endif
-#else
- #define CINDEX_LINKAGE
-#endif
-
-#ifdef __GNUC__
- #define CINDEX_DEPRECATED __attribute__((deprecated))
-#else
- #ifdef _MSC_VER
- #define CINDEX_DEPRECATED __declspec(deprecated)
- #else
- #define CINDEX_DEPRECATED
- #endif
-#endif
-
/** \defgroup CINDEX libclang: C Interface to Clang
*
* The C Interface to Clang provides a relatively small API that exposes
@@ -157,39 +139,6 @@ typedef struct CXVersion {
} CXVersion;
/**
- * \defgroup CINDEX_STRING String manipulation routines
- *
- * @{
- */
-
-/**
- * \brief A character string.
- *
- * The \c CXString type is used to return strings from the interface when
- * the ownership of that string might different from one call to the next.
- * Use \c clang_getCString() to retrieve the string data and, once finished
- * with the string data, call \c clang_disposeString() to free the string.
- */
-typedef struct {
- void *data;
- unsigned private_flags;
-} CXString;
-
-/**
- * \brief Retrieve the character data associated with the given string.
- */
-CINDEX_LINKAGE const char *clang_getCString(CXString string);
-
-/**
- * \brief Free the given string,
- */
-CINDEX_LINKAGE void clang_disposeString(CXString string);
-
-/**
- * @}
- */
-
-/**
* \brief Provides a shared context for creating translation units.
*
* It provides two options:
@@ -1109,7 +1058,14 @@ enum CXTranslationUnit_Flags {
* This option can be used to search for declarations/definitions while
* ignoring the usages.
*/
- CXTranslationUnit_SkipFunctionBodies = 0x40
+ CXTranslationUnit_SkipFunctionBodies = 0x40,
+
+ /**
+ * \brief Used to indicate that brief documentation comments should be
+ * included into the set of code completions returned from this translation
+ * unit.
+ */
+ CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80
};
/**
@@ -3188,6 +3144,19 @@ CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
/**
+ * \brief Given a cursor pointing to a C++ method call or an ObjC message,
+ * returns non-zero if the method/message is "dynamic", meaning:
+ *
+ * For a C++ method: the call is virtual.
+ * For an ObjC message: the receiver is an object instance, not 'super' or a
+ * specific class.
+ *
+ * If the method/message is "static" or the cursor does not point to a
+ * method/message, it will return zero.
+ */
+CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
+
+/**
* \brief Given a cursor that represents a declaration, return the associated
* comment's source range. The range may include multiple consecutive comments
* with whitespace in between.
@@ -3201,6 +3170,12 @@ CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
/**
+ * \brief Given a cursor that represents a declaration, return the associated
+ * \\brief paragraph; otherwise return the first paragraph.
+ */
+CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
+
+/**
* @}
*/
@@ -3831,6 +3806,14 @@ clang_getCompletionAnnotation(CXCompletionString completion_string,
CINDEX_LINKAGE CXString
clang_getCompletionParent(CXCompletionString completion_string,
enum CXCursorKind *kind);
+
+/**
+ * \brief Retrieve the brief documentation comment attached to the declaration
+ * that corresponds to the given completion string.
+ */
+CINDEX_LINKAGE CXString
+clang_getCompletionBriefComment(CXCompletionString completion_string);
+
/**
* \brief Retrieve a completion string for an arbitrary declaration or macro
* definition cursor.
@@ -3881,7 +3864,13 @@ enum CXCodeComplete_Flags {
* \brief Whether to include code patterns for language constructs
* within the set of code completions, e.g., for loops.
*/
- CXCodeComplete_IncludeCodePatterns = 0x02
+ CXCodeComplete_IncludeCodePatterns = 0x02,
+
+ /**
+ * \brief Whether to include brief documentation within the set of code
+ * completions returned.
+ */
+ CXCodeComplete_IncludeBriefComments = 0x04
};
/**
45 include/clang-c/Platform.h
View
@@ -0,0 +1,45 @@
+/*===-- clang-c/Platform.h - C Index platform decls -------------*- C -*-===*\
+|* *|
+|* The LLVM Compiler Infrastructure *|
+|* *|
+|* This file is distributed under the University of Illinois Open Source *|
+|* License. See LICENSE.TXT for details. *|
+|* *|
+|*===----------------------------------------------------------------------===*|
+|* *|
+|* This header provides platform specific macros (dllimport, deprecated, ...) *|
+|* *|
+\*===----------------------------------------------------------------------===*/
+
+#ifndef CLANG_C_PLATFORM_H
+#define CLANG_C_PLATFORM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* MSVC DLL import/export. */
+#ifdef _MSC_VER
+ #ifdef _CINDEX_LIB_
+ #define CINDEX_LINKAGE __declspec(dllexport)
+ #else
+ #define CINDEX_LINKAGE __declspec(dllimport)
+ #endif
+#else
+ #define CINDEX_LINKAGE
+#endif
+
+#ifdef __GNUC__
+ #define CINDEX_DEPRECATED __attribute__((deprecated))
+#else
+ #ifdef _MSC_VER
+ #define CINDEX_DEPRECATED __declspec(deprecated)
+ #else
+ #define CINDEX_DEPRECATED
+ #endif
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif
9 include/clang/AST/ASTContext.h
View
@@ -599,6 +599,10 @@ class ASTContext : public RefCountedBase<ASTContext> {
mutable QualType AutoDeductTy; // Deduction against 'auto'.
mutable QualType AutoRRefDeductTy; // Deduction against 'auto &&'.
+ // Type used to help define __builtin_va_list for some targets.
+ // The type is built when constructing 'BuiltinVaListDecl'.
+ mutable QualType VaListTagTy;
+
ASTContext(LangOptions& LOpts, SourceManager &SM, const TargetInfo *t,
IdentifierTable &idents, SelectorTable &sels,
Builtin::Context &builtins,
@@ -1185,6 +1189,11 @@ class ASTContext : public RefCountedBase<ASTContext> {
return getTypeDeclType(getBuiltinVaListDecl());
}
+ /// \brief Retrieve the C type declaration corresponding to the predefined
+ /// __va_list_tag type used to help define the __builtin_va_list type for
+ /// some targets.
+ QualType getVaListTagType() const;
+
/// getCVRQualifiedType - Returns a type with additional const,
/// volatile, or restrict qualifiers.
QualType getCVRQualifiedType(QualType T, unsigned CVR) const {
4 include/clang/AST/ASTVector.h
View
@@ -374,7 +374,7 @@ void ASTVector<T>::grow(ASTContext &C, size_t MinSize) {
NewCapacity = MinSize;
// Allocate the memory from the ASTContext.
- T *NewElts = new (C) T[NewCapacity];
+ T *NewElts = new (C, llvm::alignOf<T>()) T[NewCapacity];
// Copy the elements over.
if (llvm::is_class<T>::value) {
@@ -387,7 +387,7 @@ void ASTVector<T>::grow(ASTContext &C, size_t MinSize) {
memcpy(NewElts, Begin, CurSize * sizeof(T));
}
- C.Deallocate(Begin);
+ // ASTContext never frees any memory.
Begin = NewElts;
End = NewElts+CurSize;
Capacity = Begin+NewCapacity;
49 include/clang/AST/CommentBriefParser.h
View
@@ -0,0 +1,49 @@
+//===--- CommentBriefParser.h - Dumb comment parser -------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines a very simple Doxygen comment parser.
+//
+//===----------------------------------------------------------------------===//
+
+
+#ifndef LLVM_CLANG_AST_BRIEF_COMMENT_PARSER_H
+#define LLVM_CLANG_AST_BRIEF_COMMENT_PARSER_H
+
+#include "clang/AST/CommentLexer.h"
+
+namespace clang {
+namespace comments {
+
+/// A very simple comment parser that extracts just the brief description or
+/// first paragraph.
+class BriefParser {
+ Lexer &L;
+
+ /// Current lookahead token.
+ Token Tok;
+
+ SourceLocation ConsumeToken() {
+ SourceLocation Loc = Tok.getLocation();
+ L.lex(Tok);
+ return Loc;
+ }
+
+public:
+ BriefParser(Lexer &L);
+
+ /// Return \\brief paragraph, if it exists; otherwise return the first
+ /// paragraph.
+ std::string Parse();
+};
+
+} // end namespace comments
+} // end namespace clang
+
+#endif
+
345 include/clang/AST/CommentLexer.h
View
@@ -0,0 +1,345 @@
+//===--- CommentLexer.h - Lexer for structured comments ---------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines lexer for structured comments and supporting token class.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_AST_COMMENT_LEXER_H
+#define LLVM_CLANG_AST_COMMENT_LEXER_H
+
+#include "clang/Basic/SourceManager.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace clang {
+namespace comments {
+
+class Lexer;
+
+namespace tok {
+enum TokenKind {
+ eof,
+ newline,
+ text,
+ command,
+ verbatim_block_begin,
+ verbatim_block_line,
+ verbatim_block_end,
+ verbatim_line_name,
+ verbatim_line_text,
+ html_tag_open, // <tag
+ html_ident, // attr
+ html_equals, // =
+ html_quoted_string, // "blah\"blah" or 'blah\'blah'
+ html_greater, // >
+ html_tag_close // </tag>
+};
+} // end namespace tok
+
+class CommentOptions {
+public:
+ bool Markdown;
+};
+
+/// \brief Comment token.
+class Token {
+ friend class Lexer;
+
+ /// The location of the token.
+ SourceLocation Loc;
+
+ /// The actual kind of the token.
+ tok::TokenKind Kind;
+
+ /// Length of the token spelling in comment. Can be 0 for synthenized
+ /// tokens.
+ unsigned Length;
+
+ /// Contains text value associated with a token.
+ const char *TextPtr1;
+ unsigned TextLen1;
+
+public:
+ SourceLocation getLocation() const LLVM_READONLY { return Loc; }
+ void setLocation(SourceLocation SL) { Loc = SL; }
+
+ tok::TokenKind getKind() const LLVM_READONLY { return Kind; }
+ void setKind(tok::TokenKind K) { Kind = K; }
+
+ bool is(tok::TokenKind K) const LLVM_READONLY { return Kind == K; }
+ bool isNot(tok::TokenKind K) const LLVM_READONLY { return Kind != K; }
+
+ unsigned getLength() const LLVM_READONLY { return Length; }
+ void setLength(unsigned L) { Length = L; }
+
+ StringRef getText() const LLVM_READONLY {
+ assert(is(tok::text));
+ return StringRef(TextPtr1, TextLen1);
+ }
+
+ void setText(StringRef Text) {
+ assert(is(tok::text));
+ TextPtr1 = Text.data();
+ TextLen1 = Text.size();
+ }
+
+ StringRef getCommandName() const LLVM_READONLY {
+ assert(is(tok::command));
+ return StringRef(TextPtr1, TextLen1);
+ }
+
+ void setCommandName(StringRef Name) {
+ assert(is(tok::command));
+ TextPtr1 = Name.data();
+ TextLen1 = Name.size();
+ }
+
+ StringRef getVerbatimBlockName() const LLVM_READONLY {
+ assert(is(tok::verbatim_block_begin) || is(tok::verbatim_block_end));
+ return StringRef(TextPtr1, TextLen1);
+ }
+
+ void setVerbatimBlockName(StringRef Name) {
+ assert(is(tok::verbatim_block_begin) || is(tok::verbatim_block_end));
+ TextPtr1 = Name.data();
+ TextLen1 = Name.size();
+ }
+
+ StringRef getVerbatimBlockText() const LLVM_READONLY {
+ assert(is(tok::verbatim_block_line));
+ return StringRef(TextPtr1, TextLen1);
+ }
+
+ void setVerbatimBlockText(StringRef Text) {
+ assert(is(tok::verbatim_block_line));
+ TextPtr1 = Text.data();
+ TextLen1 = Text.size();
+ }
+
+ /// Returns the name of verbatim line command.
+ StringRef getVerbatimLineName() const LLVM_READONLY {
+ assert(is(tok::verbatim_line_name));
+ return StringRef(TextPtr1, TextLen1);
+ }
+
+ void setVerbatimLineName(StringRef Name) {
+ assert(is(tok::verbatim_line_name));
+ TextPtr1 = Name.data();
+ TextLen1 = Name.size();
+ }
+
+ StringRef getVerbatimLineText() const LLVM_READONLY {
+ assert(is(tok::verbatim_line_text));
+ return StringRef(TextPtr1, TextLen1);
+ }
+
+ void setVerbatimLineText(StringRef Text) {
+ assert(is(tok::verbatim_line_text));
+ TextPtr1 = Text.data();
+ TextLen1 = Text.size();
+ }
+
+ StringRef getHTMLTagOpenName() const LLVM_READONLY {
+ assert(is(tok::html_tag_open));
+ return StringRef(TextPtr1, TextLen1);
+ }
+
+ void setHTMLTagOpenName(StringRef Name) {
+ assert(is(tok::html_tag_open));
+ TextPtr1 = Name.data();
+ TextLen1 = Name.size();
+ }
+
+ StringRef getHTMLIdent() const LLVM_READONLY {
+ assert(is(tok::html_ident));
+ return StringRef(TextPtr1, TextLen1);
+ }
+
+ void setHTMLIdent(StringRef Name) {
+ assert(is(tok::html_ident));
+ TextPtr1 = Name.data();
+ TextLen1 = Name.size();
+ }
+
+ StringRef getHTMLQuotedString() const LLVM_READONLY {
+ assert(is(tok::html_quoted_string));
+ return StringRef(TextPtr1, TextLen1);
+ }
+
+ void setHTMLQuotedString(StringRef Str) {
+ assert(is(tok::html_quoted_string));
+ TextPtr1 = Str.data();
+ TextLen1 = Str.size();
+ }
+
+ StringRef getHTMLTagCloseName() const LLVM_READONLY {
+ assert(is(tok::html_tag_close));
+ return StringRef(TextPtr1, TextLen1);
+ }
+
+ void setHTMLTagCloseName(StringRef Name) {
+ assert(is(tok::html_tag_close));
+ TextPtr1 = Name.data();
+ TextLen1 = Name.size();
+ }
+
+ void dump(const Lexer &L, const SourceManager &SM) const;
+};
+
+/// \brief Comment lexer.
+class Lexer {
+private:
+ Lexer(const Lexer&); // DO NOT IMPLEMENT
+ void operator=(const Lexer&); // DO NOT IMPLEMENT
+
+ const char *const BufferStart;
+ const char *const BufferEnd;
+ SourceLocation FileLoc;
+ CommentOptions CommOpts;
+
+ const char *BufferPtr;
+
+ /// One past end pointer for the current comment. For BCPL comments points
+ /// to newline or BufferEnd, for C comments points to star in '*/'.
+ const char *CommentEnd;
+
+ enum LexerCommentState {
+ LCS_BeforeComment,
+ LCS_InsideBCPLComment,
+ LCS_InsideCComment,
+ LCS_BetweenComments
+ };
+
+ /// Low-level lexer state, track if we are inside or outside of comment.
+ LexerCommentState CommentState;
+
+ enum LexerState {
+ /// Lexing normal comment text
+ LS_Normal,
+
+ /// Finished lexing verbatim block beginning command, will lex first body
+ /// line.
+ LS_VerbatimBlockFirstLine,
+
+ /// Lexing verbatim block body line-by-line, skipping line-starting
+ /// decorations.
+ LS_VerbatimBlockBody,
+
+ /// Finished lexing verbatim line beginning command, will lex text (one
+ /// line).
+ LS_VerbatimLineText,
+
+ /// Finished lexing \verbatim <TAG \endverbatim part, lexing tag attributes.
+ LS_HTMLOpenTag
+ };
+
+ /// Current lexing mode.
+ LexerState State;
+
+ /// A verbatim-like block command eats every character (except line starting
+ /// decorations) until matching end command is seen or comment end is hit.
+ struct VerbatimBlockCommand {
+ StringRef BeginName;
+ StringRef EndName;
+ };
+
+ typedef SmallVector<VerbatimBlockCommand, 4> VerbatimBlockCommandVector;
+
+ /// Registered verbatim-like block commands.
+ VerbatimBlockCommandVector VerbatimBlockCommands;
+
+ /// If State is LS_VerbatimBlock, contains the the name of verbatim end
+ /// command, including command marker.
+ SmallString<16> VerbatimBlockEndCommandName;
+
+ bool isVerbatimBlockCommand(StringRef BeginName, StringRef &EndName) const;
+
+ /// A verbatim-like line command eats everything until a newline is seen or
+ /// comment end is hit.
+ struct VerbatimLineCommand {
+ StringRef Name;
+ };
+
+ typedef SmallVector<VerbatimLineCommand, 4> VerbatimLineCommandVector;
+
+ /// Registered verbatim-like line commands.
+ VerbatimLineCommandVector VerbatimLineCommands;
+
+ bool isVerbatimLineCommand(StringRef Name) const;
+
+ void formTokenWithChars(Token &Result, const char *TokEnd,
+ tok::TokenKind Kind) {
+ const unsigned TokLen = TokEnd - BufferPtr;
+ Result.setLocation(getSourceLocation(BufferPtr));
+ Result.setKind(Kind);
+ Result.setLength(TokLen);
+#ifndef NDEBUG
+ Result.TextPtr1 = "<UNSET>";
+ Result.TextLen1 = 7;
+#endif
+ BufferPtr = TokEnd;
+ }
+
+ SourceLocation getSourceLocation(const char *Loc) const {
+ assert(Loc >= BufferStart && Loc <= BufferEnd &&
+ "Location out of range for this buffer!");
+
+ const unsigned CharNo = Loc - BufferStart;
+ return FileLoc.getLocWithOffset(CharNo);
+ }
+
+ /// Eat string matching regexp \code \s*\* \endcode.
+ void skipLineStartingDecorations();
+
+ /// Lex stuff inside comments. CommentEnd should be set correctly.
+ void lexCommentText(Token &T);
+
+ void setupAndLexVerbatimBlock(Token &T,
+ const char *TextBegin,
+ char Marker, StringRef EndName);
+
+ void lexVerbatimBlockFirstLine(Token &T);
+
+ void lexVerbatimBlockBody(Token &T);
+
+ void setupAndLexVerbatimLine(Token &T, const char *TextBegin);
+
+ void lexVerbatimLineText(Token &T);
+
+ void setupAndLexHTMLOpenTag(Token &T);
+
+ void lexHTMLOpenTag(Token &T);
+
+ void lexHTMLCloseTag(Token &T);
+
+public:
+ Lexer(SourceLocation FileLoc, const CommentOptions &CommOpts,
+ const char *BufferStart, const char *BufferEnd);
+
+ void lex(Token &T);
+
+ StringRef getSpelling(const Token &Tok,
+ const SourceManager &SourceMgr,
+ bool *Invalid = NULL) const;
+
+ /// \brief Register a new verbatim block command.
+ void addVerbatimBlockCommand(StringRef BeginName, StringRef EndName);
+
+ /// \brief Register a new verbatim line command.
+ void addVerbatimLineCommand(StringRef Name);
+};
+
+} // end namespace comments
+} // end namespace clang
+
+#endif
+
10 include/clang/AST/Decl.h
View
@@ -2151,6 +2151,16 @@ class FieldDecl : public DeclaratorDecl {
}
unsigned getBitWidthValue(const ASTContext &Ctx) const;
+ /// setBitWidth - Set the bit-field width for this member.
+ // Note: used by some clients (i.e., do not remove it).
+ void setBitWidth(Expr *Width);
+ /// removeBitWidth - Remove the bit-field width from this member.
+ // Note: used by some clients (i.e., do not remove it).
+ void removeBitWidth() {
+ assert(isBitField() && "no bitfield width to remove");
+ InitializerOrBitWidth.setPointer(0);
+ }
+
/// getInClassInitStyle - Get the kind of (C++11) in-class initializer which
/// this field has.
InClassInitStyle getInClassInitStyle() const {
13 include/clang/AST/DeclCXX.h
View
@@ -41,6 +41,7 @@ class CXXFinalOverriderMap;
class CXXIndirectPrimaryBaseSet;
class FriendDecl;
class LambdaExpr;
+class UsingDecl;
/// \brief Represents any kind of function declaration, whether it is a
/// concrete function or a function template.
@@ -541,13 +542,21 @@ class CXXRecordDecl : public RecordDecl {
/// \brief Retrieve the set of direct base classes.
CXXBaseSpecifier *getBases() const {
- return Bases.get(Definition->getASTContext().getExternalSource());
+ if (!Bases.isOffset())
+ return Bases.get(0);
+ return getBasesSlowCase();
}
/// \brief Retrieve the set of virtual base classes.
CXXBaseSpecifier *getVBases() const {
- return VBases.get(Definition->getASTContext().getExternalSource());
+ if (!VBases.isOffset())
+ return VBases.get(0);
+ return getVBasesSlowCase();
}
+
+ private:
+ CXXBaseSpecifier *getBasesSlowCase() const;
+ CXXBaseSpecifier *getVBasesSlowCase() const;
} *DefinitionData;
/// \brief Describes a C++ closure type (generated by a lambda expression).
8 include/clang/AST/DeclFriend.h
View
@@ -71,10 +71,12 @@ class FriendDecl : public Decl {
: Decl(Decl::Friend, Empty), NextFriend() { }
FriendDecl *getNextFriend() {
- return cast_or_null<FriendDecl>(
- NextFriend.get(getASTContext().getExternalSource()));
+ if (!NextFriend.isOffset())
+ return cast_or_null<FriendDecl>(NextFriend.get(0));
+ return getNextFriendSlowCase();
}
-
+ FriendDecl *getNextFriendSlowCase();
+
public:
static FriendDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L, FriendUnion Friend_,
46 include/clang/AST/Expr.h
View
@@ -15,6 +15,7 @@
#define LLVM_CLANG_AST_EXPR_H
#include "clang/AST/APValue.h"
+#include "clang/AST/Decl.h"
#include "clang/AST/Stmt.h"
#include "clang/AST/Type.h"
#include "clang/AST/DeclAccessPair.h"
@@ -634,6 +635,13 @@ class Expr : public Stmt {
/// ParenExpr or CastExprs, returning their operand.
Expr *IgnoreParenNoopCasts(ASTContext &Ctx) LLVM_READONLY;
+ /// Ignore parentheses and derived-to-base casts.
+ Expr *ignoreParenBaseCasts() LLVM_READONLY;
+
+ const Expr *ignoreParenBaseCasts() const LLVM_READONLY {
+ return const_cast<Expr*>(this)->ignoreParenBaseCasts();
+ }
+
/// \brief Determine whether this expression is a default function argument.
///
/// Default arguments are implicitly generated in the abstract syntax tree
@@ -665,12 +673,14 @@ class Expr : public Stmt {
static bool hasAnyTypeDependentArguments(llvm::ArrayRef<Expr *> Exprs);
- /// \brief If we have class type (or pointer to class type), return the
- /// class decl. Return NULL otherwise.
+ /// \brief For an expression of class type or pointer to class type,
+ /// return the most derived class decl the expression is known to refer to.
///
/// If this expression is a cast, this method looks through it to find the
- /// most derived decl that can be infered from the expression.
- const CXXRecordDecl *getMostDerivedClassDeclForType() const;
+ /// most derived decl that can be inferred from the expression.
+ /// This is valid because derived-to-base conversions have undefined
+ /// behavior if the object isn't dynamically of the derived type.
+ const CXXRecordDecl *getBestDynamicClassType() const;
static bool classof(const Stmt *T) {
return T->getStmtClass() >= firstExprConstant &&
@@ -1154,16 +1164,8 @@ class IntegerLiteral : public Expr, public APIntStorage {
public:
// type should be IntTy, LongTy, LongLongTy, UnsignedIntTy, UnsignedLongTy,
// or UnsignedLongLongTy
- IntegerLiteral(ASTContext &C, const llvm::APInt &V,
- QualType type, SourceLocation l)
- : Expr(IntegerLiteralClass, type, VK_RValue, OK_Ordinary, false, false,
- false, false),
- Loc(l) {
- assert(type->isIntegerType() && "Illegal type in IntegerLiteral");
- assert(V.getBitWidth() == C.getIntWidth(type) &&
- "Integer type is not the correct size for constant.");
- setValue(C, V);
- }
+ IntegerLiteral(ASTContext &C, const llvm::APInt &V, QualType type,
+ SourceLocation l);
/// \brief Returns a new integer literal with value 'V' and type 'type'.
/// \param type - either IntTy, LongTy, LongLongTy, UnsignedIntTy,
@@ -1241,22 +1243,10 @@ class FloatingLiteral : public Expr, private APFloatStorage {
SourceLocation Loc;
FloatingLiteral(ASTContext &C, const llvm::APFloat &V, bool isexact,
- QualType Type, SourceLocation L)
- : Expr(FloatingLiteralClass, Type, VK_RValue, OK_Ordinary, false, false,
- false, false), Loc(L) {
- FloatingLiteralBits.IsIEEE =
- &C.getTargetInfo().getLongDoubleFormat() == &llvm::APFloat::IEEEquad;
- FloatingLiteralBits.IsExact = isexact;
- setValue(C, V);
- }
+ QualType Type, SourceLocation L);
/// \brief Construct an empty floating-point literal.
- explicit FloatingLiteral(ASTContext &C, EmptyShell Empty)
- : Expr(FloatingLiteralClass, Empty) {
- FloatingLiteralBits.IsIEEE =
- &C.getTargetInfo().getLongDoubleFormat() == &llvm::APFloat::IEEEquad;
- FloatingLiteralBits.IsExact = false;
- }
+ explicit FloatingLiteral(ASTContext &C, EmptyShell Empty);
public:
static FloatingLiteral *Create(ASTContext &C, const llvm::APFloat &V,
1  include/clang/AST/ExprCXX.h
View
@@ -14,6 +14,7 @@
#ifndef LLVM_CLANG_AST_EXPRCXX_H
#define LLVM_CLANG_AST_EXPRCXX_H
+#include "clang/AST/Decl.h"
#include "clang/AST/Expr.h"
#include "clang/AST/UnresolvedSet.h"
#include "clang/AST/TemplateBase.h"
2  include/clang/AST/OperationKinds.h
View
@@ -291,7 +291,7 @@ enum CastKind {
CK_CopyAndAutoreleaseBlockObject
};
-#define CK_Invalid ((CastKind) -1)
+static const CastKind CK_Invalid = static_cast<CastKind>(-1);
enum BinaryOperatorKind {
// Operators listed in order of precedence.
49 include/clang/AST/RawCommentList.h
View
@@ -15,22 +15,23 @@
namespace clang {
+class ASTContext;
class ASTReader;
class RawComment {
public:
enum CommentKind {
- CK_Invalid, ///< Invalid comment
- CK_OrdinaryBCPL, ///< Any normal BCPL comments
- CK_OrdinaryC, ///< Any normal C comment
- CK_BCPLSlash, ///< \code /// stuff \endcode
- CK_BCPLExcl, ///< \code //! stuff \endcode
- CK_JavaDoc, ///< \code /** stuff */ \endcode
- CK_Qt, ///< \code /*! stuff */ \endcode, also used by HeaderDoc
- CK_Merged ///< Two or more Doxygen comments merged together
+ RCK_Invalid, ///< Invalid comment
+ RCK_OrdinaryBCPL, ///< Any normal BCPL comments
+ RCK_OrdinaryC, ///< Any normal C comment
+ RCK_BCPLSlash, ///< \code /// stuff \endcode
+ RCK_BCPLExcl, ///< \code //! stuff \endcode
+ RCK_JavaDoc, ///< \code /** stuff */ \endcode
+ RCK_Qt, ///< \code /*! stuff */ \endcode, also used by HeaderDoc
+ RCK_Merged ///< Two or more documentation comments merged together
};
- RawComment() : Kind(CK_Invalid), IsAlmostTrailingComment(false) { }
+ RawComment() : Kind(RCK_Invalid), IsAlmostTrailingComment(false) { }
RawComment(const SourceManager &SourceMgr, SourceRange SR,
bool Merged = false);
@@ -40,11 +41,11 @@ class RawComment {
}
bool isInvalid() const LLVM_READONLY {
- return Kind == CK_Invalid;
+ return Kind == RCK_Invalid;
}
bool isMerged() const LLVM_READONLY {
- return Kind == CK_Merged;
+ return Kind == RCK_Merged;
}
/// Returns true if it is a comment that should be put after a member:
@@ -53,7 +54,7 @@ class RawComment {
/// \code /**< stuff */ \endcode
/// \code /*!< stuff */ \endcode
bool isTrailingComment() const LLVM_READONLY {
- assert(isDoxygen());
+ assert(isDocumentation());
return IsTrailingComment;
}
@@ -64,13 +65,13 @@ class RawComment {
return IsAlmostTrailingComment;
}
- /// Returns true if this comment is not a Doxygen comment.
+ /// Returns true if this comment is not a documentation comment.
bool isOrdinary() const LLVM_READONLY {
- return (Kind == CK_OrdinaryBCPL) || (Kind == CK_OrdinaryC);
+ return (Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC);
}
- /// Returns true if this comment any kind of a Doxygen comment.
- bool isDoxygen() const LLVM_READONLY {
+ /// Returns true if this comment any kind of a documentation comment.
+ bool isDocumentation() const LLVM_READONLY {
return !isInvalid() && !isOrdinary();
}
@@ -91,11 +92,21 @@ class RawComment {
unsigned getBeginLine(const SourceManager &SM) const;
unsigned getEndLine(const SourceManager &SM) const;
+ const char *getBriefText(const ASTContext &Context) const {
+ if (BriefTextValid)
+ return BriefText;
+
+ return extractBriefText(Context);
+ }
+
private:
SourceRange Range;
mutable StringRef RawText;
- mutable bool RawTextValid : 1; ///< True if RawText is valid
+ mutable const char *BriefText;
+
+ mutable bool RawTextValid : 1; ///< True if RawText is valid
+ mutable bool BriefTextValid : 1; ///< True if BriefText is valid
unsigned Kind : 3;
@@ -110,7 +121,7 @@ class RawComment {
/// \brief Constructor for AST deserialization.
RawComment(SourceRange SR, CommentKind K, bool IsTrailingComment,
bool IsAlmostTrailingComment) :
- Range(SR), RawTextValid(false), Kind(K),
+ Range(SR), RawTextValid(false), BriefTextValid(false), Kind(K),
IsTrailingComment(IsTrailingComment),
IsAlmostTrailingComment(IsAlmostTrailingComment),
BeginLineValid(false), EndLineValid(false)
@@ -118,6 +129,8 @@ class RawComment {
StringRef getRawTextSlow(const SourceManager &SourceMgr) const;
+ const char *extractBriefText(const ASTContext &Context) const;
+
friend class ASTReader;
};
23 include/clang/AST/RecordLayout.h
View
@@ -14,10 +14,9 @@
#ifndef LLVM_CLANG_AST_LAYOUTINFO_H
#define LLVM_CLANG_AST_LAYOUTINFO_H
-#include "llvm/Support/DataTypes.h"
-#include "llvm/ADT/DenseMap.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/DeclCXX.h"
+#include "llvm/ADT/DenseMap.h"
namespace clang {
class ASTContext;
@@ -210,26 +209,6 @@ class ASTRecordLayout {
return CXXInfo->VBaseOffsets[VBase].VBaseOffset;
}
- /// getBaseClassOffsetInBits - Get the offset, in bits, for the given
- /// base class.
- uint64_t getBaseClassOffsetInBits(const CXXRecordDecl *Base) const {
- assert(CXXInfo && "Record layout does not have C++ specific info!");
- assert(CXXInfo->BaseOffsets.count(Base) && "Did not find base!");
-
- return getBaseClassOffset(Base).getQuantity() *
- Base->getASTContext().getCharWidth();
- }
-
- /// getVBaseClassOffsetInBits - Get the offset, in bits, for the given
- /// base class.
- uint64_t getVBaseClassOffsetInBits(const CXXRecordDecl *VBase) const {
- assert(CXXInfo && "Record layout does not have C++ specific info!");
- assert(CXXInfo->VBaseOffsets.count(VBase) && "Did not find base!");
-
- return getVBaseClassOffset(VBase).getQuantity() *
- VBase->getASTContext().getCharWidth();
- }
-
CharUnits getSizeOfLargestEmptySubobject() const {
assert(CXXInfo && "Record layout does not have C++ specific info!");
return CXXInfo->SizeOfLargestEmptySubobject;
4 include/clang/AST/RecursiveASTVisitor.h
View
@@ -1762,7 +1762,7 @@ 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) &&
- (!D->isCXXForRangeDecl() || shouldVisitImplicitCode()))
+ (!D->isCXXForRangeDecl() || getDerived().shouldVisitImplicitCode()))
TRY_TO(TraverseStmt(D->getInit()));
return true;
}
@@ -1881,7 +1881,7 @@ DEF_TRAVERSE_STMT(ObjCAtTryStmt, { })
DEF_TRAVERSE_STMT(ObjCForCollectionStmt, { })
DEF_TRAVERSE_STMT(ObjCAutoreleasePoolStmt, { })
DEF_TRAVERSE_STMT(CXXForRangeStmt, {
- if (!shouldVisitImplicitCode()) {
+ if (!getDerived().shouldVisitImplicitCode()) {
TRY_TO(TraverseStmt(S->getLoopVarStmt()));
TRY_TO(TraverseStmt(S->getRangeInit()));
TRY_TO(TraverseStmt(S->getBody()));
22 include/clang/AST/Stmt.h
View
@@ -19,7 +19,6 @@
#include "clang/AST/PrettyPrinter.h"
#include "clang/AST/StmtIterator.h"
#include "clang/AST/DeclGroup.h"
-#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Compiler.h"
@@ -37,9 +36,11 @@ namespace clang {
class ParmVarDecl;
class QualType;
class IdentifierInfo;
+ class LabelDecl;
class SourceManager;
class StringLiteral;
class SwitchStmt;
+ class VarDecl;
//===--------------------------------------------------------------------===//
// ExprIterator - Iterators for iterating over Stmt* arrays that contain
@@ -545,20 +546,13 @@ class CompoundStmt : public Stmt {
Stmt** Body;
SourceLocation LBracLoc, RBracLoc;
public:
- CompoundStmt(ASTContext& C, Stmt **StmtStart, unsigned NumStmts,
- SourceLocation LB, SourceLocation RB)
- : Stmt(CompoundStmtClass), LBracLoc(LB), RBracLoc(RB) {
- CompoundStmtBits.NumStmts = NumStmts;
- assert(CompoundStmtBits.NumStmts == NumStmts &&
- "NumStmts doesn't fit in bits of CompoundStmtBits.NumStmts!");
-
- if (NumStmts == 0) {
- Body = 0;
- return;
- }
+ CompoundStmt(ASTContext &C, Stmt **StmtStart, unsigned NumStmts,
+ SourceLocation LB, SourceLocation RB);
- Body = new (C) Stmt*[NumStmts];
- memcpy(Body, StmtStart, NumStmts * sizeof(*Body));
+ // \brief Build an empty compound statment with a location.
+ explicit CompoundStmt(SourceLocation Loc)
+ : Stmt(CompoundStmtClass), Body(0), LBracLoc(Loc), RBracLoc(Loc) {
+ CompoundStmtBits.NumStmts = 0;
}
// \brief Build an empty compound statement.
3  include/clang/Analysis/Analyses/ThreadSafety.h
View
@@ -60,7 +60,8 @@ enum AccessKind {
enum LockErrorKind {
LEK_LockedSomeLoopIterations,
LEK_LockedSomePredecessors,
- LEK_LockedAtEndOfFunction
+ LEK_LockedAtEndOfFunction,
+ LEK_NotLockedAtEndOfFunction
};
/// Handler class for thread safety warnings.
43 include/clang/Basic/ABI.h
View
@@ -6,10 +6,11 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
-// These enums/classes describe ABI related information about constructors,
-// destructors and thunks.
-//
+///
+/// \file
+/// \brief Enums/classes describing ABI related information about constructors,
+/// destructors and thunks.
+///
//===----------------------------------------------------------------------===//
#ifndef CLANG_BASIC_ABI_H
@@ -19,27 +20,27 @@
namespace clang {
-/// CXXCtorType - C++ constructor types
+/// \brief C++ constructor types.
enum CXXCtorType {
- Ctor_Complete, // Complete object ctor
- Ctor_Base, // Base object ctor
- Ctor_CompleteAllocating // Complete object allocating ctor
+ Ctor_Complete, ///< Complete object ctor
+ Ctor_Base, ///< Base object ctor
+ Ctor_CompleteAllocating ///< Complete object allocating ctor
};
-/// CXXDtorType - C++ destructor types
+/// \brief C++ destructor types.
enum CXXDtorType {
- Dtor_Deleting, // Deleting dtor
- Dtor_Complete, // Complete object dtor
- Dtor_Base // Base object dtor
+ Dtor_Deleting, ///< Deleting dtor
+ Dtor_Complete, ///< Complete object dtor
+ Dtor_Base ///< Base object dtor
};
-/// ReturnAdjustment - A return adjustment.
+/// \brief A return adjustment.
struct ReturnAdjustment {
- /// NonVirtual - The non-virtual adjustment from the derived object to its
+ /// \brief The non-virtual adjustment from the derived object to its
/// nearest virtual base.
int64_t NonVirtual;
- /// VBaseOffsetOffset - The offset (in bytes), relative to the address point
+ /// \brief The offset (in bytes), relative to the address point
/// of the virtual base class offset.
int64_t VBaseOffsetOffset;
@@ -63,13 +64,13 @@ struct ReturnAdjustment {
}
};
-/// ThisAdjustment - A 'this' pointer adjustment.
+/// \brief A \c this pointer adjustment.
struct ThisAdjustment {
- /// NonVirtual - The non-virtual adjustment from the derived object to its
+ /// \brief The non-virtual adjustment from the derived object to its
/// nearest virtual base.
int64_t NonVirtual;
- /// VCallOffsetOffset - The offset (in bytes), relative to the address point,
+ /// \brief The offset (in bytes), relative to the address point,
/// of the virtual call offset.
int64_t VCallOffsetOffset;
@@ -93,13 +94,13 @@ struct ThisAdjustment {
}
};
-/// ThunkInfo - The 'this' pointer adjustment as well as an optional return
+/// \brief The \c this pointer adjustment as well as an optional return
/// adjustment for a thunk.
struct ThunkInfo {
- /// This - The 'this' pointer adjustment.
+ /// \brief The \c this pointer adjustment.
ThisAdjustment This;
- /// Return - The return adjustment.
+ /// \brief The return adjustment.
ReturnAdjustment Return;
ThunkInfo() { }
14 include/clang/Basic/AddressSpaces.h
View
@@ -6,10 +6,11 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
-// This file provides definitions for the various language-specific address
-// spaces.
-//
+///
+/// \file
+/// \brief Provides definitions for the various language-specific address
+/// spaces.
+///
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_BASIC_ADDRESSSPACES_H
@@ -19,8 +20,9 @@ namespace clang {
namespace LangAS {
-/// This enum defines the set of possible language-specific address spaces.
-/// It uses a high starting offset so as not to conflict with any address
+/// \brief Defines the set of possible language-specific address spaces.
+///
+/// This uses a high starting offset so as not to conflict with any address
/// space used by a target.