LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 4157 - Using ENV generates wrong source code
Summary: Using ENV generates wrong source code
Status: RESOLVED FIXED
Alias: None
Product: tools
Classification: Unclassified
Component: TableGen (show other bugs)
Version: trunk
Hardware: Other Linux
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-05 03:39 PDT by Martin Nowack
Modified: 2009-05-05 07:34 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments
Patch for ENV bug (400 bytes, patch)
2009-05-05 03:39 PDT, Martin Nowack
Details
Correct patch (389 bytes, patch)
2009-05-05 04:24 PDT, Martin Nowack
Details
As previous patch but with correct path from LLVM root dir (434 bytes, patch)
2009-05-05 06:58 PDT, Martin Nowack
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Nowack 2009-05-05 03:39:08 PDT
Created attachment 2953 [details]
Patch for ENV bug

Using the ENV macro the generated code contains an additional brace ')' - the attached patch fixes the behavior.
The problem persists at least since 2.5 and also in trunk.

Thanks.
Comment 1 Martin Nowack 2009-05-05 04:24:14 PDT
Created attachment 2954 [details]
Correct patch

Sorry, previous patch was not correct.

Following examples for the td file:

(cmd_line "gcc -o $OUTFILE $INFILE $ENV(FOO)/bar")

generates:
vec.push_back(checkCString(std::getenv("STMLIBDIR")) + std::string("/libtanger-stm.a")));

The middle brace is left over. 
That brace is generated under every condition (before return statement) but this makes no sense as braces are generated correctly (same number for opening and closing braces) for both cases CALL and ENV.
Comment 2 Martin Nowack 2009-05-05 06:58:29 PDT
Created attachment 2955 [details]
As previous patch but with correct path from LLVM root dir
Comment 3 Mikhail Glushenkov 2009-05-05 07:34:43 PDT
Applied, thanks!