[llvm-bugs] [Bug 45790] New: Changing behavior in clang::SourceRange.getEnd() between clang versions 8 and 9 and later
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon May 4 01:25:33 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45790
Bug ID: 45790
Summary: Changing behavior in clang::SourceRange.getEnd()
between clang versions 8 and 9 and later
Product: clang
Version: 9.0
Hardware: PC
OS: FreeBSD
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: lunkov at gmail.com
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
Created attachment 23439
--> https://bugs.llvm.org/attachment.cgi?id=23439&action=edit
Test file
I encountered a backward compatibility violation in the
clang::SourceRange.getEnd() between versions 8 and 9 in the following code:
------
void MyPPCallbacks::If(SourceLocation Loc, SourceRange ConditionRange,
ConditionValueKind ConditionValue){
[...]
StartPos = SM.getFileOffset(SM.getFileLoc(Loc));
EndPos = SM.getFileOffset(SM.getFileLoc(ConditionRange.getEnd()));
[...]
}
------
This code has worked without changing behavior since clang version 3.4.
In clang version 8.0, EndPos is ALWAYS equal to the position of the macro
character following the last, and in clang version 9.0 and later EndPos takes
on a value depending on the expression.
In the following example, you can see the difference which values EndPos takes
in various expressions in clang 8 and clang 9:
------
#define TEST_MACRO 1
// example 1
#if defined(TEST_MACRO) && !defined(UNDEF_TEST_MACRO)
// ^ clang 8
ConditionRange.getEnd().getRawEncoding() = 91
// ^ clang 9
ConditionRange.getEnd().getRawEncoding() = 90
#endif
// example 2
#if TEST_MACRO && TEST_MACRO
// ^ clang 8
ConditionRange.getEnd().getRawEncoding() = 364
// ^ clang 9 ConditionRange.getEnd().getRawEncoding() =
2147495546
#endif
// example 3
#if TEST_MACRO
// ^ clang 8 ConditionRange.getEnd().getRawEncoding() = 572
// ^ clang 9 ConditionRange.getEnd().getRawEncoding() = 2147495548
#endif
int main(){ return 0; }
------
In examples 2 and 3, the value of getRawEncoding() for some reason changes
depending on the length of the file.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200504/030329d2/attachment.html>
More information about the llvm-bugs
mailing list