C++: Fix maxCols.

This commit is contained in:
Geoffrey White
2021-06-04 13:04:23 +01:00
parent ea96826810
commit a93246d28b
3 changed files with 8 additions and 8 deletions

View File

@@ -128,7 +128,7 @@ deprecated library class LocationExpr extends Location, @location_expr { }
* Gets the length of the longest line in file `f`.
*/
pragma[nomagic]
private int maxCols(File f) { result = max(Location l | l.getFile() = f | l.getEndColumn()) }
private int maxCols(File f) { result = max(Location l | l.getFile() = f | [l.getStartColumn(), l.getEndColumn()]) }
/**
* A C/C++ element that has a location in a file

View File

@@ -1,6 +1,6 @@
| charloc.cpp | 1 | 39 | 39 | 1 |
| charloc.cpp | 2 | 48 | 48 | 2 |
| charloc.cpp | 3 | 52 | 52 | 3 |
| charloc.cpp | 4 | 64 | 64 | 4 |
| charloc.cpp | (...) | 65 | 65 | (...) |
| charloc.cpp | ... + ... | 48 | 52 | ... + ..., 2, 3 |
| charloc.cpp | 1 | 47 | 47 | 1 |
| charloc.cpp | 2 | 58 | 58 | 2 |
| charloc.cpp | 3 | 62 | 62 | 3 |
| charloc.cpp | 4 | 78 | 78 | 4 |
| charloc.cpp | (...) | 77 | 79 | (...), 4 |
| charloc.cpp | ... + ... | 58 | 62 | ... + ..., 2, 3 |

View File

@@ -11,7 +11,7 @@ class Link extends Top {
* Gets the length of the longest line in file `f`.
*/
pragma[nomagic]
private int maxCols(File f) { result = max(Location l | l.getFile() = f | l.getEndColumn()) }
private int maxCols(File f) { result = max(Location l | l.getFile() = f | [l.getStartColumn(), l.getEndColumn()]) }
/**
* Gets the location of an element that has a link-to-definition (in a similar manner to