Packaging: Refactor the cpp libraries

This PR separates the core cpp packs into `codeql/cpp-queries` and
`codeql/cpp-all`.

There are very few lines of code changed. Almost all changes are moving
files around.
This commit is contained in:
Andrew Eisenberg
2021-08-16 17:23:27 -07:00
parent e566fb9c5a
commit 2c5dd2dfa3
421 changed files with 175 additions and 159 deletions

View File

@@ -0,0 +1,69 @@
/**
* Provides classes representing C/C++ `#include`, `#include_next`, and `#import` preprocessor
* directives.
*/
import semmle.code.cpp.Preprocessor
/**
* A C/C++ `#include`, `#include_next`, or `#import` preprocessor
* directive. The following example contains four different `Include`
* directives:
* ```
* #include "header.h"
* #include <string>
* #include_next <header2.h>
* #import <header3.h>
* ```
*/
class Include extends PreprocessorDirective, @ppd_include {
override string toString() { result = "#include " + this.getIncludeText() }
/**
* Gets the token which occurs after `#include`, for example `"filename"`
* or `<filename>`.
*/
string getIncludeText() { result = getHead() }
/** Gets the file directly included by this `#include`. */
File getIncludedFile() { includes(underlyingElement(this), unresolveElement(result)) }
/**
* Gets a file which might be transitively included by this `#include`.
*
* Note that as this isn't computed within the context of a particular
* translation unit, it is often a slight over-approximation.
*/
predicate provides(File l) {
exists(Include i | this.getAnInclude*() = i and i.getIncludedFile() = l)
}
/**
* A `#include` which appears in the file directly included by this
* `#include`.
*/
Include getAnInclude() { this.getIncludedFile() = result.getFile() }
}
/**
* A `#include_next` preprocessor directive (a non-standard extension to
* C/C++). For example the following code contains one `IncludeNext` directive:
* ```
* #include_next <header2.h>
* ```
*/
class IncludeNext extends Include, @ppd_include_next {
override string toString() { result = "#include_next " + getIncludeText() }
}
/**
* A `#import` preprocessor directive (used heavily in Objective C, and
* supported by GCC as an extension in C). For example the following code
* contains one `Import` directive:
* ```
* #import <header3.h>
* ```
*/
class Import extends Include, @ppd_objc_import {
override string toString() { result = "#import " + getIncludeText() }
}