diff --git a/config/dbscheme-fragments.json b/config/dbscheme-fragments.json index b8c79fc8f3a..c2a9a5e734b 100644 --- a/config/dbscheme-fragments.json +++ b/config/dbscheme-fragments.json @@ -1,11 +1,13 @@ { "files": [ + "cpp/ql/lib/semmlecode.cpp.dbscheme", "javascript/ql/lib/semmlecode.javascript.dbscheme", "python/ql/lib/semmlecode.python.dbscheme", "ruby/ql/lib/ruby.dbscheme", "ql/ql/src/ql.dbscheme" ], "fragments": [ + "/*- Compilations -*/", "/*- External data -*/", "/*- Files and folders -*/", "/*- Diagnostic messages -*/", @@ -21,6 +23,7 @@ "/*- DEPRECATED: Snapshot date -*/", "/*- DEPRECATED: Duplicate code -*/", "/*- DEPRECATED: Version control data -*/", + "/*- C++ dbscheme -*/", "/*- JavaScript-specific part -*/", "/*- Ruby dbscheme -*/", "/*- Erb dbscheme -*/", diff --git a/cpp/ql/lib/semmle/code/cpp/Location.qll b/cpp/ql/lib/semmle/code/cpp/Location.qll index 1af519b6698..8b0a78f91aa 100644 --- a/cpp/ql/lib/semmle/code/cpp/Location.qll +++ b/cpp/ql/lib/semmle/code/cpp/Location.qll @@ -8,7 +8,7 @@ import semmle.code.cpp.File /** * A location of a C/C++ artifact. */ -class Location extends @location { +class Location extends @location_default { /** Gets the container corresponding to this location. */ pragma[nomagic] Container getContainer() { this.fullLocationInfo(result, _, _, _, _) } diff --git a/cpp/ql/lib/semmlecode.cpp.dbscheme b/cpp/ql/lib/semmlecode.cpp.dbscheme index e70d0b65318..827dbc206ea 100644 --- a/cpp/ql/lib/semmlecode.cpp.dbscheme +++ b/cpp/ql/lib/semmlecode.cpp.dbscheme @@ -1,3 +1,4 @@ +/*- Compilations -*/ /** * An invocation of the compiler. Note that more than one file may be @@ -138,6 +139,7 @@ compilation_finished( float elapsed_seconds : float ref ); +/*- External data -*/ /** * External data, loaded from CSV files during snapshot creation. See @@ -145,17 +147,76 @@ compilation_finished( * for more information. */ externalData( - int id : @externalDataElement, - string path : string ref, - int column: int ref, - string value : string ref + int id : @externalDataElement, + string path : string ref, + int column: int ref, + string value : string ref ); +/*- Source location prefix -*/ + /** * The source location of the snapshot. */ sourceLocationPrefix(string prefix : string ref); +/*- Files and folders -*/ + +/** + * The location of an element. + * The location spans column `startcolumn` of line `startline` to + * column `endcolumn` of line `endline` in file `file`. + * For more information, see + * [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/). + */ +locations_default( + unique int id: @location_default, + int file: @file ref, + int beginLine: int ref, + int beginColumn: int ref, + int endLine: int ref, + int endColumn: int ref +); + +files( + unique int id: @file, + string name: string ref +); + +folders( + unique int id: @folder, + string name: string ref +); + +@container = @file | @folder + +containerparent( + int parent: @container ref, + unique int child: @container ref +); + +/*- Lines of code -*/ + +numlines( + int element_id: @sourceline ref, + int num_lines: int ref, + int num_code: int ref, + int num_comment: int ref +); + +/*- Diagnostic messages -*/ + +diagnostics( + unique int id: @diagnostic, + int severity: int ref, + string error_tag: string ref, + string error_message: string ref, + string full_error_message: string ref, + int location: @location_default ref +); + +/*- C++ dbscheme -*/ + /** * Information about packages that provide code used during compilation. * The `id` is just a unique identifier. @@ -179,36 +240,6 @@ header_to_external_package( int package : @external_package ref ); -/* - * Version history - */ - -svnentries( - unique int id : @svnentry, - string revision : string ref, - string author : string ref, - date revisionDate : date ref, - int changeSize : int ref -) - -svnaffectedfiles( - int id : @svnentry ref, - int file : @file ref, - string action : string ref -) - -svnentrymsg( - unique int id : @svnentry ref, - string message : string ref -) - -svnchurn( - int commit : @svnentry ref, - int file : @file ref, - int addedLines : int ref, - int deletedLines : int ref -) - /* * C++ dbscheme */ @@ -218,61 +249,9 @@ extractor_version( string frontend_version: string ref ) -@location = @location_default ; - -/** - * The location of an element. - * The location spans column `startcolumn` of line `startline` to - * column `endcolumn` of line `endline` in file `file`. - * For more information, see - * [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/). - */ -locations_default( - /** The location of an element that is not an expression or a statement. */ - unique int id: @location_default, - int container: @container ref, - int startLine: int ref, - int startColumn: int ref, - int endLine: int ref, - int endColumn: int ref -); - /** An element for which line-count information is available. */ @sourceline = @file | @function | @variable | @enumconstant | @xmllocatable; -numlines( - int element_id: @sourceline ref, - int num_lines: int ref, - int num_code: int ref, - int num_comment: int ref -); - -diagnostics( - unique int id: @diagnostic, - int severity: int ref, - string error_tag: string ref, - string error_message: string ref, - string full_error_message: string ref, - int location: @location ref -); - -files( - unique int id: @file, - string name: string ref -); - -folders( - unique int id: @folder, - string name: string ref -); - -@container = @folder | @file - -containerparent( - int parent: @container ref, - unique int child: @container ref -); - fileannotations( int id: @file ref, int kind: int ref, @@ -298,7 +277,7 @@ case @macroinvocation.kind of macroinvocations( unique int id: @macroinvocation, int macro_id: @ppd_define ref, - int location: @location ref, + int location: @location_default ref, int kind: int ref ); @@ -313,7 +292,7 @@ macroparent( // to which a macro invocation is bound macrolocationbind( int id: @macroinvocation ref, - int location: @location ref + int location: @location_default ref ); #keyset[invocation, argument_index] @@ -419,7 +398,7 @@ fun_decls( int function: @function ref, int type_id: @type ref, string name: string ref, - int location: @location ref + int location: @location_default ref ); fun_def(unique int id: @fun_decl ref); fun_specialized(unique int id: @fun_decl ref); @@ -471,7 +450,7 @@ var_decls( int variable: @variable ref, int type_id: @type ref, string name: string ref, - int location: @location ref + int location: @location_default ref ); var_def(unique int id: @var_decl ref); var_specialized(int id: @var_decl ref); @@ -488,7 +467,7 @@ var_requires( type_decls( unique int id: @type_decl, int type_id: @type ref, - int location: @location ref + int location: @location_default ref ); type_def(unique int id: @type_decl ref); type_decl_top( @@ -502,8 +481,8 @@ type_requires( namespace_decls( unique int id: @namespace_decl, int namespace_id: @namespace ref, - int location: @location ref, - int bodylocation: @location ref + int location: @location_default ref, + int bodylocation: @location_default ref ); case @using.kind of @@ -515,7 +494,7 @@ case @using.kind of usings( unique int id: @using, int element_id: @element ref, - int location: @location ref, + int location: @location_default ref, int kind: int ref ); @@ -529,7 +508,7 @@ static_asserts( unique int id: @static_assert, int condition : @expr ref, string message : string ref, - int location: @location ref, + int location: @location_default ref, int enclosing : @element ref ); @@ -585,7 +564,7 @@ enumconstants( int index: int ref, int type_id: @type ref, string name: string ref, - int location: @location ref + int location: @location_default ref ); @variable = @localscopevariable | @globalvariable | @membervariable; @@ -889,7 +868,7 @@ is_proxy_class_for( type_mentions( unique int id: @type_mention, int type_id: @type ref, - int location: @location ref, + int location: @location_default ref, // a_symbol_reference_kind from the frontend. int kind: int ref ); @@ -946,7 +925,7 @@ template_template_argument_value( concept_templates( unique int concept_id: @concept_template, string name: string ref, - int location: @location ref + int location: @location_default ref ); concept_instantiation( unique int to: @concept_id ref, @@ -1050,7 +1029,7 @@ attributes( int kind: int ref, string name: string ref, string name_space: string ref, - int location: @location ref + int location: @location_default ref ); case @attribute.kind of @@ -1067,7 +1046,7 @@ attribute_args( int kind: int ref, int attribute: @attribute ref, int index: int ref, - int location: @location ref + int location: @location_default ref ); case @attribute_arg.kind of @@ -1156,7 +1135,7 @@ derivations( int sub: @type ref, int index: int ref, int super: @type ref, - int location: @location ref + int location: @location_default ref ); derspecifiers( @@ -1190,7 +1169,7 @@ frienddecls( unique int id: @frienddecl, int type_id: @type ref, int decl_id: @declaration ref, - int location: @location ref + int location: @location_default ref ); @declaredtype = @usertype ; @@ -1247,7 +1226,7 @@ frienddecls( comments( unique int id: @comment, string contents: string ref, - int location: @location ref + int location: @location_default ref ); commentbinding( @@ -1369,7 +1348,7 @@ namequalifiers( unique int id: @namequalifier, unique int qualifiableelement: @namequalifiableelement ref, int qualifyingelement: @namequalifyingelement ref, - int location: @location ref + int location: @location_default ref ); varbind( @@ -1638,7 +1617,7 @@ initialisers( unique int init: @initialiser, int var: @accessible ref, unique int expr: @expr ref, - int location: @location ref + int location: @location_default ref ); braced_initialisers( @@ -1657,7 +1636,7 @@ expr_ancestor( exprs( unique int id: @expr, int kind: int ref, - int location: @location ref + int location: @location_default ref ); expr_reuse( @@ -2131,7 +2110,7 @@ lambda_capture( int field: @membervariable ref, boolean captured_by_reference: boolean ref, boolean is_implicit: boolean ref, - int location: @location ref + int location: @location_default ref ); @funbindexpr = @routineexpr @@ -2159,7 +2138,7 @@ fold( stmts( unique int id: @stmt, int kind: int ref, - int location: @location ref + int location: @location_default ref ); case @stmt.kind of @@ -2344,7 +2323,7 @@ jumpinfo( preprocdirects( unique int id: @preprocdirect, int kind: int ref, - int location: @location ref + int location: @location_default ref ); case @preprocdirect.kind of 0 = @ppd_if @@ -2400,76 +2379,73 @@ link_parent( int link_target : @link_target ref ); -/* XML Files */ +/*- XML Files -*/ -xmlEncoding(unique int id: @file ref, string encoding: string ref); +xmlEncoding( + unique int id: @file ref, + string encoding: string ref +); xmlDTDs( - unique int id: @xmldtd, - string root: string ref, - string publicId: string ref, - string systemId: string ref, - int fileid: @file ref + unique int id: @xmldtd, + string root: string ref, + string publicId: string ref, + string systemId: string ref, + int fileid: @file ref ); xmlElements( - unique int id: @xmlelement, - string name: string ref, - int parentid: @xmlparent ref, - int idx: int ref, - int fileid: @file ref + unique int id: @xmlelement, + string name: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int fileid: @file ref ); xmlAttrs( - unique int id: @xmlattribute, - int elementid: @xmlelement ref, - string name: string ref, - string value: string ref, - int idx: int ref, - int fileid: @file ref + unique int id: @xmlattribute, + int elementid: @xmlelement ref, + string name: string ref, + string value: string ref, + int idx: int ref, + int fileid: @file ref ); xmlNs( - int id: @xmlnamespace, - string prefixName: string ref, - string URI: string ref, - int fileid: @file ref + int id: @xmlnamespace, + string prefixName: string ref, + string URI: string ref, + int fileid: @file ref ); xmlHasNs( - int elementId: @xmlnamespaceable ref, - int nsId: @xmlnamespace ref, - int fileid: @file ref + int elementId: @xmlnamespaceable ref, + int nsId: @xmlnamespace ref, + int fileid: @file ref ); xmlComments( - unique int id: @xmlcomment, - string text: string ref, - int parentid: @xmlparent ref, - int fileid: @file ref + unique int id: @xmlcomment, + string text: string ref, + int parentid: @xmlparent ref, + int fileid: @file ref ); xmlChars( - unique int id: @xmlcharacters, - string text: string ref, - int parentid: @xmlparent ref, - int idx: int ref, - int isCDATA: int ref, - int fileid: @file ref + unique int id: @xmlcharacters, + string text: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int isCDATA: int ref, + int fileid: @file ref ); @xmlparent = @file | @xmlelement; @xmlnamespaceable = @xmlelement | @xmlattribute; xmllocations( - int xmlElement: @xmllocatable ref, - int location: @location_default ref + int xmlElement: @xmllocatable ref, + int location: @location_default ref ); -@xmllocatable = @xmlcharacters - | @xmlelement - | @xmlcomment - | @xmlattribute - | @xmldtd - | @file - | @xmlnamespace; +@xmllocatable = @xmlcharacters | @xmlelement | @xmlcomment | @xmlattribute | @xmldtd | @file | @xmlnamespace;